test(core): API Permission Test Cases for ticket_base model
ref: #731 #723
This commit is contained in:
@ -4,6 +4,8 @@ from django.test import (
|
||||
TestCase
|
||||
)
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
|
||||
|
||||
def pytest_pycollect_makeitem(collector, name, obj):
|
||||
@ -25,3 +27,62 @@ def pytest_pycollect_makeitem(collector, name, obj):
|
||||
@pytest.fixture(autouse=True)
|
||||
def enable_db_access_for_all_tests(db): # pylint: disable=W0613:unused-argument
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def create_model(request, django_db_blocker):
|
||||
|
||||
item = None
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
item = request.cls.model.objects.create(
|
||||
**request.cls.kwargs_create_item
|
||||
)
|
||||
|
||||
request.cls.item = item
|
||||
|
||||
yield item
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
request.cls.item.delete()
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def organization_one(django_db_blocker):
|
||||
|
||||
item = None
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
item = Organization.objects.create(
|
||||
name = 'org one'
|
||||
)
|
||||
|
||||
yield item
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
item.delete()
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def organization_two(django_db_blocker):
|
||||
|
||||
item = None
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
item = Organization.objects.create(
|
||||
name = 'org two'
|
||||
)
|
||||
|
||||
yield item
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
item.delete()
|
||||
|
Reference in New Issue
Block a user