@ -1,14 +1,18 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from access.models.contact import Contact
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture( scope = 'class')
|
@pytest.fixture( scope = 'class')
|
||||||
def model(request):
|
def model(model_contact):
|
||||||
|
|
||||||
request.cls.model = Contact
|
yield model_contact
|
||||||
|
|
||||||
yield request.cls.model
|
@pytest.fixture( scope = 'class')
|
||||||
|
def model_kwargs(request, kwargs_contact):
|
||||||
|
|
||||||
del request.cls.model
|
request.cls.kwargs_create_item = kwargs_contact.copy()
|
||||||
|
|
||||||
|
yield kwargs_contact.copy()
|
||||||
|
|
||||||
|
if hasattr(request.cls, 'kwargs_create_item'):
|
||||||
|
del request.cls.kwargs_create_item
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
from access.tests.unit.person.test_unit_person_api_fields import (
|
from access.tests.unit.person.test_unit_person_api_fields import (
|
||||||
PersonAPIInheritedCases
|
PersonAPIInheritedCases
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.model_contact
|
||||||
class ContactAPITestCases(
|
class ContactAPITestCases(
|
||||||
PersonAPIInheritedCases,
|
PersonAPIInheritedCases,
|
||||||
):
|
):
|
||||||
@ -33,6 +36,7 @@ class ContactAPIInheritedCases(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.module_access
|
||||||
class ContactAPIPyTest(
|
class ContactAPIPyTest(
|
||||||
ContactAPITestCases,
|
ContactAPITestCases,
|
||||||
):
|
):
|
||||||
|
@ -9,14 +9,11 @@ from access.tests.unit.person.test_unit_person_model import (
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.model_contact
|
||||||
class ContactModelTestCases(
|
class ContactModelTestCases(
|
||||||
PersonModelInheritedCases,
|
PersonModelInheritedCases,
|
||||||
):
|
):
|
||||||
|
|
||||||
kwargs_create_item: dict = {
|
|
||||||
'email': 'ipweird@unit.test',
|
|
||||||
}
|
|
||||||
|
|
||||||
sub_model_type = 'contact'
|
sub_model_type = 'contact'
|
||||||
"""Sub Model Type
|
"""Sub Model Type
|
||||||
|
|
||||||
@ -24,55 +21,49 @@ class ContactModelTestCases(
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
parameterized_fields: dict = {
|
@property
|
||||||
"email": {
|
def parameterized_class_attributes(self):
|
||||||
'field_type': models.fields.CharField,
|
|
||||||
'field_parameter_default_exists': False,
|
return {
|
||||||
'field_parameter_verbose_name_type': str,
|
'_is_submodel': {
|
||||||
},
|
'value': True
|
||||||
"directory": {
|
},
|
||||||
'field_type': models.fields.BooleanField,
|
'url_model_name': {
|
||||||
'field_parameter_default_exists': True,
|
'type': str,
|
||||||
'field_parameter_default_value': True,
|
'value': 'entity'
|
||||||
'field_parameter_verbose_name_type': str,
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def parameterized_fields(self):
|
||||||
|
|
||||||
|
return {
|
||||||
|
'directory': {
|
||||||
|
'blank': True,
|
||||||
|
'default': True,
|
||||||
|
'field_type': models.BooleanField,
|
||||||
|
'null': False,
|
||||||
|
'unique': False,
|
||||||
|
},
|
||||||
|
'email': {
|
||||||
|
'blank': False,
|
||||||
|
'default': models.fields.NOT_PROVIDED,
|
||||||
|
'field_type': models.EmailField,
|
||||||
|
'null': False,
|
||||||
|
'unique': True,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_class_inherits_contact(self):
|
def test_class_inherits_contact(self, model):
|
||||||
""" Class inheritence
|
""" Class inheritence
|
||||||
|
|
||||||
TenancyObject must inherit SaveHistory
|
TenancyObject must inherit SaveHistory
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert issubclass(self.model, Contact)
|
assert issubclass(model, Contact)
|
||||||
|
|
||||||
|
|
||||||
# def test_attribute_value_history_app_label(self):
|
|
||||||
# """Attribute Type
|
|
||||||
|
|
||||||
# history_app_label has been set, override this test case with the value
|
|
||||||
# of attribute `history_app_label`
|
|
||||||
# """
|
|
||||||
|
|
||||||
# assert self.model.history_app_label == 'access'
|
|
||||||
|
|
||||||
|
|
||||||
def test_attribute_value_history_model_name(self):
|
|
||||||
"""Attribute Type
|
|
||||||
|
|
||||||
history_model_name has been set, override this test case with the value
|
|
||||||
of attribute `history_model_name`
|
|
||||||
"""
|
|
||||||
|
|
||||||
assert self.model.history_model_name == 'contact'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_function_value_get_url(self):
|
|
||||||
|
|
||||||
assert self.item.get_url() == '/api/v2/access/entity/contact/' + str(self.item.id)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -83,28 +74,19 @@ class ContactModelInheritedCases(
|
|||||||
|
|
||||||
Test Cases for Ticket models that inherit from model Entity
|
Test Cases for Ticket models that inherit from model Entity
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
kwargs_create_item: dict = {}
|
|
||||||
|
|
||||||
model = None
|
|
||||||
|
|
||||||
sub_model_type = None
|
|
||||||
"""Ticket Sub Model Type
|
|
||||||
|
|
||||||
Ticket sub-models must have this attribute defined in `ModelNam.Meta.sub_model_type`
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.module_access
|
||||||
class ContactModelPyTest(
|
class ContactModelPyTest(
|
||||||
ContactModelTestCases,
|
ContactModelTestCases,
|
||||||
):
|
):
|
||||||
|
|
||||||
|
|
||||||
def test_function_value_get_related_model(self):
|
def test_function_value_get_related_model(self, model_instance):
|
||||||
"""Function test
|
"""Function test
|
||||||
|
|
||||||
Confirm function `get_related_model` is None for base model
|
Confirm function `get_related_model` is None for base model
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert self.item.get_related_model() is None
|
assert model_instance.get_related_model() is None
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.contact import Contact
|
from access.models.contact import Contact
|
||||||
@ -7,6 +9,7 @@ from access.tests.unit.person.test_unit_person_viewset import (
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.model_contact
|
||||||
class ViewsetTestCases(
|
class ViewsetTestCases(
|
||||||
PersonViewsetInheritedCases,
|
PersonViewsetInheritedCases,
|
||||||
):
|
):
|
||||||
@ -28,6 +31,7 @@ class ContactViewsetInheritedCases(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.module_access
|
||||||
class ContactViewsetTest(
|
class ContactViewsetTest(
|
||||||
ViewsetTestCases,
|
ViewsetTestCases,
|
||||||
TestCase,
|
TestCase,
|
||||||
|
@ -1107,6 +1107,7 @@ markers = [
|
|||||||
"model_configgroups: Selects Config Group tests.",
|
"model_configgroups: Selects Config Group tests.",
|
||||||
"model_configgrouphosts: Selects Config Group Hosts tests.",
|
"model_configgrouphosts: Selects Config Group Hosts tests.",
|
||||||
"model_configgroupsoftware: Selects Config Group Software tests.",
|
"model_configgroupsoftware: Selects Config Group Software tests.",
|
||||||
|
"model_contact: Selects test for model Contact.",
|
||||||
"model_cluster: Selects Cluster tests.",
|
"model_cluster: Selects Cluster tests.",
|
||||||
"model_clustertype: Selects Cluster Type tests.",
|
"model_clustertype: Selects Cluster Type tests.",
|
||||||
"model_device: Select all Device tests",
|
"model_device: Select all Device tests",
|
||||||
|
Reference in New Issue
Block a user