feat(core): Add to Centurion Model an attribute to set the models tag
ref: #773 #767 #576
This commit is contained in:
@ -54,7 +54,13 @@ class ClassTestCases:
|
||||
Ensure that field `param_field_name` has a type of `param_type`
|
||||
"""
|
||||
|
||||
assert type(getattr(test_class, param_field_name)) is param_type
|
||||
if type(getattr(test_class, param_field_name)) is property:
|
||||
|
||||
assert type( getattr(test_class, param_field_name).fget(test_class) ) is param_type
|
||||
|
||||
else:
|
||||
|
||||
assert type(getattr(test_class, param_field_name)) is param_type
|
||||
|
||||
|
||||
|
||||
@ -67,4 +73,11 @@ class ClassTestCases:
|
||||
Ensure that field `param_field_name`has a value of `param_value`
|
||||
"""
|
||||
|
||||
assert getattr(test_class, param_field_name) == param_value
|
||||
|
||||
if type(getattr(test_class, param_field_name)) is property:
|
||||
|
||||
assert getattr(test_class, param_field_name).fget(test_class) == param_value
|
||||
|
||||
else:
|
||||
|
||||
assert getattr(test_class, param_field_name) == param_value
|
||||
|
@ -34,6 +34,13 @@ class CenturionModel(
|
||||
to their own `urls.py` file from `api/urls_v2.py`.
|
||||
"""
|
||||
|
||||
model_tag: str = None
|
||||
"""Model Tag
|
||||
|
||||
String that is used as this models tag. Used within ticketing for linking a
|
||||
model to a ticket and wihin markdown for referencing a model.
|
||||
"""
|
||||
|
||||
url_model_name: str = None
|
||||
"""URL Model Name override
|
||||
|
||||
|
@ -52,6 +52,12 @@ class CenturionAbstractModelTestCases(
|
||||
'logger': None,
|
||||
'user': None,
|
||||
}
|
||||
},
|
||||
'model_tag': {
|
||||
'type': str,
|
||||
},
|
||||
'url_model_name': {
|
||||
'type': type(None),
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,10 +248,34 @@ class CenturionAbstractModelInheritedCases(
|
||||
|
||||
|
||||
|
||||
def test_model_tag_defined(self, model):
|
||||
""" Model Tag
|
||||
|
||||
Ensure that the model has a tag defined.
|
||||
"""
|
||||
|
||||
assert model.model_tag is not None
|
||||
|
||||
|
||||
|
||||
class CenturionAbstractModelPyTest(
|
||||
CenturionAbstractModelTestCases,
|
||||
):
|
||||
|
||||
@property
|
||||
def parameterized_class_attributes(self):
|
||||
|
||||
return {
|
||||
'model_tag': {
|
||||
'type': type(None),
|
||||
'value': None,
|
||||
},
|
||||
'url_model_name': {
|
||||
'type': type(None),
|
||||
'value': None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
def test_model_is_abstract(self, model):
|
||||
|
@ -38,6 +38,14 @@ class CenturionAuditModelTestCases(
|
||||
},
|
||||
'_notes_enabled': {
|
||||
'value': False,
|
||||
},
|
||||
'model_tag': {
|
||||
'type': type(None),
|
||||
'value': None,
|
||||
},
|
||||
'url_model_name': {
|
||||
'type': str,
|
||||
'value': 'centurionaudit',
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,6 +135,17 @@ class CenturionAuditModelPyTest(
|
||||
):
|
||||
|
||||
|
||||
|
||||
@pytest.mark.xfail( reason = 'This model is an abstract model')
|
||||
def test_model_tag_defined(self, model):
|
||||
""" Model Tag
|
||||
|
||||
Ensure that the model has a tag defined.
|
||||
"""
|
||||
|
||||
assert model.model_tag is not None
|
||||
|
||||
|
||||
def test_method_clean_fields_default_attributes(self, model_instance):
|
||||
"""Test Class Method
|
||||
|
||||
|
@ -17,6 +17,7 @@ class MetaAbstractModelTestCases(
|
||||
CenturionSubAbstractModelInheritedCases,
|
||||
):
|
||||
|
||||
|
||||
def test_method_centurionauditsub_clean_fields_called(self, mocker, model_instance):
|
||||
"""Test Class Method
|
||||
|
||||
@ -44,6 +45,17 @@ class MetaAbstractModelPyTest(
|
||||
MetaAbstractModelTestCases,
|
||||
):
|
||||
|
||||
|
||||
@pytest.mark.xfail( reason = 'This model is an abstract model')
|
||||
def test_model_tag_defined(self, model):
|
||||
""" Model Tag
|
||||
|
||||
Ensure that the model has a tag defined.
|
||||
"""
|
||||
|
||||
assert model.model_tag is not None
|
||||
|
||||
|
||||
def test_model_is_abstract(self, model):
|
||||
|
||||
assert model._meta.abstract
|
||||
|
@ -36,6 +36,31 @@ class CenturionSubAbstractModelPyTest(
|
||||
CenturionSubAbstractModelTestCases,
|
||||
):
|
||||
|
||||
@property
|
||||
def parameterized_class_attributes(self):
|
||||
|
||||
return {
|
||||
'model_tag': {
|
||||
'type': type(None),
|
||||
'value': None,
|
||||
},
|
||||
'url_model_name': {
|
||||
'type': type(None),
|
||||
'value': None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.xfail( reason = 'This model is an abstract model')
|
||||
def test_model_tag_defined(self, model):
|
||||
""" Model Tag
|
||||
|
||||
Ensure that the model has a tag defined.
|
||||
"""
|
||||
|
||||
assert model.model_tag is not None
|
||||
|
||||
|
||||
def test_model_is_abstract(self, model):
|
||||
|
||||
assert model._meta.abstract
|
||||
|
@ -37,6 +37,10 @@ class GitGroupModelTestCases(
|
||||
'type': type(None),
|
||||
'value': None,
|
||||
},
|
||||
'model_tag': {
|
||||
'type': str,
|
||||
'value': 'git_group'
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user