test(config_management): Completed ConfigGroupHost Model Tests
ref: #804 #793
This commit is contained in:
@ -372,6 +372,7 @@ class ConfigGroupHosts(
|
||||
|
||||
modified = AutoLastModifiedField()
|
||||
|
||||
|
||||
@property
|
||||
def parent_object(self):
|
||||
""" Fetch the parent object """
|
||||
@ -379,6 +380,10 @@ class ConfigGroupHosts(
|
||||
return self.group
|
||||
|
||||
|
||||
page_layout: list = []
|
||||
table_fields: list = []
|
||||
|
||||
|
||||
|
||||
class ConfigGroupSoftware(
|
||||
CenturionModel,
|
||||
|
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model(model_configgrouphost):
|
||||
|
||||
yield model_configgrouphost
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class', autouse = True)
|
||||
def model_kwargs(request, kwargs_configgrouphost):
|
||||
|
||||
request.cls.kwargs_create_item = kwargs_configgrouphost.copy()
|
||||
|
||||
yield kwargs_configgrouphost.copy()
|
||||
|
||||
if hasattr(request.cls, 'kwargs_create_item'):
|
||||
del request.cls.kwargs_create_item
|
@ -12,7 +12,7 @@ from core.tests.unit.centurion_abstract.test_unit_centurion_abstract_model impor
|
||||
|
||||
|
||||
@pytest.mark.model_config_group_hosts
|
||||
class ConfigGroupSoftwareModelTestCases(
|
||||
class ConfigGroupHostModelTestCases(
|
||||
CenturionAbstractModelInheritedCases
|
||||
):
|
||||
|
||||
@ -20,7 +20,12 @@ class ConfigGroupSoftwareModelTestCases(
|
||||
@property
|
||||
def parameterized_class_attributes(self):
|
||||
|
||||
return {}
|
||||
return {
|
||||
'model_tag': {
|
||||
'type': models.NOT_PROVIDED,
|
||||
'value': models.NOT_PROVIDED,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
parameterized_model_fields = {
|
||||
@ -48,15 +53,24 @@ class ConfigGroupSoftwareModelTestCases(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.xfail( reason = 'not required for this model' )
|
||||
def test_method_value_not_default___str__(self):
|
||||
pass
|
||||
|
||||
class ConfigGroupSoftwareModelInheritedCases(
|
||||
ConfigGroupSoftwareModelTestCases,
|
||||
@pytest.mark.xfail( reason = 'not required for this model' )
|
||||
def test_model_tag_defined(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class ConfigGroupHostModelInheritedCases(
|
||||
ConfigGroupHostModelTestCases,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class ConfigGroupSoftwareModelPyTest(
|
||||
ConfigGroupSoftwareModelTestCases,
|
||||
class ConfigGroupHostModelPyTest(
|
||||
ConfigGroupHostModelTestCases,
|
||||
):
|
||||
pass
|
||||
|
15
app/tests/fixtures/__init__.py
vendored
15
app/tests/fixtures/__init__.py
vendored
@ -39,10 +39,25 @@ from .model_centurionsubmodel import (
|
||||
model_centurionsubmodel,
|
||||
)
|
||||
|
||||
from .model_configgroup import (
|
||||
kwargs_configgroup,
|
||||
model_configgroup,
|
||||
)
|
||||
|
||||
from .model_configgrouphost import (
|
||||
kwargs_configgrouphost,
|
||||
model_configgrouphost,
|
||||
)
|
||||
|
||||
from .model_contenttype import (
|
||||
model_contenttype,
|
||||
)
|
||||
|
||||
from .model_device import (
|
||||
kwargs_device,
|
||||
model_device,
|
||||
)
|
||||
|
||||
from .model_featureflag import (
|
||||
kwargs_featureflag,
|
||||
model_featureflag,
|
||||
|
27
app/tests/fixtures/model_configgroup.py
vendored
Normal file
27
app/tests/fixtures/model_configgroup.py
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from config_management.models.groups import ConfigGroups
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model_configgroup():
|
||||
|
||||
yield ConfigGroups
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def kwargs_configgroup(django_db_blocker,
|
||||
kwargs_centurionmodel
|
||||
):
|
||||
|
||||
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
|
||||
|
||||
kwargs = {
|
||||
**kwargs_centurionmodel.copy(),
|
||||
'name': 'cg' + random_str,
|
||||
'config': {"key": "one", "existing": "dont_over_write"},
|
||||
'modified': '2024-06-03T23:00:00Z',
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
56
app/tests/fixtures/model_configgrouphost.py
vendored
Normal file
56
app/tests/fixtures/model_configgrouphost.py
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from config_management.models.groups import ConfigGroupHosts
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model_configgrouphost():
|
||||
|
||||
yield ConfigGroupHosts
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def kwargs_configgrouphost(django_db_blocker,
|
||||
kwargs_device, model_device,
|
||||
kwargs_centurionmodel, model_configgroup, kwargs_configgroup,
|
||||
):
|
||||
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
centurion_kwargs = kwargs_centurionmodel.copy()
|
||||
|
||||
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
|
||||
|
||||
host_kwargs = kwargs_device.copy()
|
||||
host_kwargs.update({
|
||||
'name': 'cgh' + str(random_str).replace(' ', '').replace(':', '').replace('+', '').replace('.', ''),
|
||||
'organization': centurion_kwargs['organization']
|
||||
})
|
||||
|
||||
host = model_device.objects.create( **host_kwargs )
|
||||
|
||||
|
||||
group_kwargs = kwargs_configgroup.copy()
|
||||
group_kwargs.update({
|
||||
'name': 'cgg' + random_str,
|
||||
'organization': centurion_kwargs['organization']
|
||||
})
|
||||
|
||||
group = model_configgroup.objects.create( **group_kwargs )
|
||||
|
||||
kwargs = {
|
||||
**centurion_kwargs,
|
||||
'host': host,
|
||||
'group': group,
|
||||
'modified': '2024-06-07T23:00:00Z',
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
host.delete()
|
||||
|
||||
group.delete()
|
24
app/tests/fixtures/model_device.py
vendored
Normal file
24
app/tests/fixtures/model_device.py
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from itam.models.device import Device
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model_device():
|
||||
|
||||
yield Device
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def kwargs_device(kwargs_centurionmodel):
|
||||
|
||||
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
|
||||
|
||||
kwargs = {
|
||||
**kwargs_centurionmodel.copy(),
|
||||
'name': 'dev' + str(random_str).replace(' ', '').replace(':', '').replace('+', '').replace('.', ''),
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
Reference in New Issue
Block a user