Django tool
Project description
shopcloud-django-toolbox
install
$ pip install shopcloud-django-toolbox
Models
Add the GID as identifier to all django models
from shopcloud_django_toolbox import GID
class FooBarModel(models.Model, GID):
pass
Testing
API standart tests
Standart template for the tests.py
file in all modules with admin and REST API`s
from shopcloud_django_toolbox.tests import BaseTestAPIEndpointDoc
from shopcloud_django_toolbox import TestAdminTestCase
from shopcloud_django_toolbox.tests import BaseTestApiAuthorization
from shopcloud_django_toolbox import SetupClass
class TestDocEntpoint(BaseTestAPIEndpointDoc):
pass
__
class TestAdminPages(TestAdminTestCase):
MODULE = 'url-name'
def test_admin_easylineitem(self):
self.run_for_model(
'url-model-name',
is_check_add=False, # deactivate when add function is deactivated
is_check_template=False, # deactivate generic template check
is_check_search=True, # activate searchbar check
)
class TestApiAuthorization(BaseTestApiAuthorization):
app_name = "url-module-name"
def test_model_foo(self):
self.run_test_endpoint("url-model-name")
def test_model_bar(self):
self.run_test_endpoint("url-model-name")
class YoutAPITest(SetupClass):
def test_api_endpint(self):
client = APIClient()
client.login(username=self.username, password=self.pwd)
r = client.get('/module/api/endpoint')
self.assertEqual(r.status_code, status.HTTP_201_CREATED)
Event
To fire events and run tasks in prarallel, need [PROJECT] to receive and run the output from log and call the API.
from shopcloud_django_toolbox import Event
class FooBarModel(models.Model):
...
def do_event(self):
event = Event(
name="de.talk-point.platform/module/model/sync",
model=self,
)
event.add_task(
queue="default",
url=f"moduke/api/model/{self.id}/action/",
json={}
)
event.fire()
deploy
# change version Number in setup.py ändern und dann erst releasen
# delete build and dist-directory
$ rm -rf build
$ rm -rf dist
$ pip3 install wheel twine
$ python3 setup.py sdist bdist_wheel
$ twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for shopcloud_django_toolbox-1.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7211a87941c8a8498d8ea69a1aa126c954cb11210e0190153718806f468a2f2 |
|
MD5 | e9fdeba0204e653f45a65b7b3bd53c01 |
|
BLAKE2b-256 | dfda8abec589c659b83eb71ca0dac460210e7d86e2558f52adb0cc6b3a752fd9 |
Close
Hashes for shopcloud_django_toolbox-1.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 224801f95b9a02608ddf7bbd01a55f50f26771972bfffd24265ba6bc00b11e5d |
|
MD5 | f3feee005cd30201f6dc50cda963cc79 |
|
BLAKE2b-256 | 945cca334d03e5a89865b6166e5d73b96347a752896da73de864d9a67a049bd7 |