refactor(config_management): Add ConfigGroupSoftware Model Tests
ref: #804 #794
This commit is contained in:
@ -0,0 +1,61 @@
|
||||
# Generated by Django 5.1.9 on 2025-06-07 04:10
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
(
|
||||
"config_management",
|
||||
"0012_alter_configgroups_config_alter_configgroups_parent",
|
||||
),
|
||||
("itam", "0014_remove_device_is_global_remove_device_slug_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="configgroupsoftware",
|
||||
name="action",
|
||||
field=models.IntegerField(
|
||||
blank=True,
|
||||
choices=[(1, "Install"), (0, "Remove")],
|
||||
help_text="ACtion to perform with this software",
|
||||
null=True,
|
||||
verbose_name="Action",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="configgroupsoftware",
|
||||
name="config_group",
|
||||
field=models.ForeignKey(
|
||||
help_text="Config group this softwre will be linked to",
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to="config_management.configgroups",
|
||||
verbose_name="Config Group",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="configgroupsoftware",
|
||||
name="software",
|
||||
field=models.ForeignKey(
|
||||
help_text="Software to add to this config Group",
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to="itam.software",
|
||||
verbose_name="Software",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="configgroupsoftware",
|
||||
name="version",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
help_text="Software Version for this config group",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to="itam.softwareversion",
|
||||
verbose_name="Verrsion",
|
||||
),
|
||||
),
|
||||
]
|
@ -399,42 +399,38 @@ class ConfigGroupSoftware(
|
||||
|
||||
config_group = models.ForeignKey(
|
||||
ConfigGroups,
|
||||
blank= False,
|
||||
default = None,
|
||||
blank = False,
|
||||
help_text = 'Config group this softwre will be linked to',
|
||||
null = False,
|
||||
on_delete=models.CASCADE,
|
||||
on_delete = models.PROTECT,
|
||||
verbose_name = 'Config Group'
|
||||
)
|
||||
|
||||
|
||||
software = models.ForeignKey(
|
||||
Software,
|
||||
blank= False,
|
||||
default = None,
|
||||
blank = False,
|
||||
help_text = 'Software to add to this config Group',
|
||||
null = False,
|
||||
on_delete=models.CASCADE,
|
||||
on_delete = models.PROTECT,
|
||||
verbose_name = 'Software'
|
||||
)
|
||||
|
||||
|
||||
action = models.IntegerField(
|
||||
blank = True,
|
||||
choices=DeviceSoftware.Actions,
|
||||
default=None,
|
||||
choices = DeviceSoftware.Actions,
|
||||
help_text = 'ACtion to perform with this software',
|
||||
null=True,
|
||||
null = True,
|
||||
verbose_name = 'Action'
|
||||
)
|
||||
|
||||
version = models.ForeignKey(
|
||||
SoftwareVersion,
|
||||
blank= True,
|
||||
default = None,
|
||||
blank = True,
|
||||
help_text = 'Software Version for this config group',
|
||||
null = True,
|
||||
on_delete=models.CASCADE,
|
||||
on_delete = models.PROTECT,
|
||||
verbose_name = 'Verrsion',
|
||||
)
|
||||
|
||||
|
@ -1,22 +1,15 @@
|
||||
from django.test import TestCase
|
||||
import pytest
|
||||
|
||||
from access.models.tenant import Tenant as Organization
|
||||
from django.db import models
|
||||
|
||||
from centurion.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
|
||||
from core.tests.unit.centurion_abstract.test_unit_centurion_abstract_model import (
|
||||
CenturionAbstractModelInheritedCases
|
||||
)
|
||||
|
||||
from config_management.models.groups import ConfigGroups, ConfigGroupSoftware
|
||||
|
||||
from itam.models.device import DeviceSoftware
|
||||
from itam.models.software import Software
|
||||
|
||||
|
||||
|
||||
class ConfigGroupSoftwareModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
class Old:
|
||||
|
||||
model = ConfigGroupSoftware
|
||||
|
||||
@ -66,3 +59,69 @@ class ConfigGroupSoftwareModel(
|
||||
"""
|
||||
|
||||
assert self.item.parent_object == self.parent_item
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_config_group_software
|
||||
class ConfigGroupSoftwareModelTestCases(
|
||||
CenturionAbstractModelInheritedCases
|
||||
):
|
||||
|
||||
|
||||
@property
|
||||
def parameterized_class_attributes(self):
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
parameterized_model_fields = {
|
||||
'config_group': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
'software': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
'action': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.IntegerField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'version': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'modified': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.DateTimeField,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ConfigGroupSoftwareModelInheritedCases(
|
||||
ConfigGroupSoftwareModelTestCases,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class ConfigGroupSoftwareModelPyTest(
|
||||
ConfigGroupSoftwareModelTestCases,
|
||||
):
|
||||
pass
|
||||
|
@ -1072,6 +1072,7 @@ markers = [
|
||||
"functional: Selects all Functional tests.",
|
||||
"meta_models: Selects Meta models",
|
||||
"model_config_group: Selects Config Group tests.",
|
||||
"model_config_group_software: Selects Config Group Software tests.",
|
||||
"model_featureflag: Feature Flag Model",
|
||||
"model_gitgroup: Selects tests for model `git group`",
|
||||
"model_knowledge_base: Selects Knowledge base tests.",
|
||||
|
Reference in New Issue
Block a user