refactor(itam): Update Test Suite for DeviceDeviceOperatingSystem model
ref:#817 closes #801
This commit is contained in:
@ -37,7 +37,6 @@ CREATE TABLE IF NOT EXISTS "itam_operatingsystem" ("is_global" bool NOT NULL, "m
|
||||
CREATE TABLE IF NOT EXISTS "itam_operatingsystemversion" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL, "operating_system_id" integer NOT NULL REFERENCES "itam_operatingsystem" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "itam_softwarecategory" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "itam_softwareversion" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "slug" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL, "software_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "itam_deviceoperatingsystem" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "version" varchar(15) NOT NULL, "installdate" datetime NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "operating_system_version_id" integer NOT NULL REFERENCES "itam_operatingsystemversion" ("id") DEFERRABLE INITIALLY DEFERRED, "device_id" integer NOT NULL UNIQUE REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "core_model_notes" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "content" text NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "content_type_id" integer NOT NULL REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED, "created_by_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "modified_by_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "config_management_config_group_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "config_management_configgroups" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "access_team_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED);
|
||||
@ -118,8 +117,8 @@ CREATE TABLE IF NOT EXISTS "devops_git_group_history" ("modelhistory_ptr_id" int
|
||||
CREATE TABLE IF NOT EXISTS "devops_github_repository_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_githubrepository" ("gitrepository_ptr_id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "devops_gitlab_repository_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_gitlabrepository" ("gitrepository_ptr_id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "devops_git_group_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_gitgroup" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "access_organization_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "access_organization_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "access_organization_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "itam_software" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "publisher_id" integer NULL REFERENCES "core_manufacturer" ("id") DEFERRABLE INITIALLY DEFERRED, "category_id" integer NULL REFERENCES "itam_softwarecategory" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "settings_usersettings" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "default_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "timezone" varchar(32) NOT NULL, "browser_mode" integer NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "settings_appsettings" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "device_model_is_global" bool NOT NULL, "device_type_is_global" bool NOT NULL, "manufacturer_is_global" bool NOT NULL, "software_is_global" bool NOT NULL, "software_categories_is_global" bool NOT NULL, "global_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "owner_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
@ -160,7 +159,6 @@ CREATE TABLE IF NOT EXISTS "assistance_knowledgebasecategory_target_team" ("id"
|
||||
CREATE TABLE IF NOT EXISTS "assistance_knowledgebasecategory" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "model_notes" text NULL, "name" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "target_user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_category_id" integer NULL REFERENCES "assistance_knowledgebasecategory" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "assistance_modelknowledgebasearticle" ("is_global" bool NOT NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "model_pk" integer NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "article_id" integer NOT NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "model" varchar(80) NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "itam_itamassetbase" ("assetbase_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "accounting_assetbase" ("id") DEFERRABLE INITIALLY DEFERRED, "itam_type" varchar(30) NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "itam_devicemodel" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "manufacturer_id" integer NULL REFERENCES "core_manufacturer" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "model_notes" text NULL);
|
||||
CREATE TABLE IF NOT EXISTS "itam_devicemodel_audithistory" ("centurionaudit_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_audithistory" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_devicemodel" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "itam_devicemodel_centurionmodelnote" ("centurionmodelnote_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_centurionmodelnote" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_devicemodel" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "itam_devicetype" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "model_notes" text NULL);
|
||||
@ -193,6 +191,8 @@ CREATE TABLE IF NOT EXISTS "django_celery_results_chordcounter" ("id" integer NO
|
||||
CREATE TABLE IF NOT EXISTS "django_celery_results_taskresult" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "task_id" varchar(255) NOT NULL UNIQUE, "status" varchar(50) NOT NULL, "content_type" varchar(128) NOT NULL, "content_encoding" varchar(64) NOT NULL, "result" text NULL, "date_done" datetime NOT NULL, "traceback" text NULL, "meta" text NULL, "task_args" text NULL, "task_kwargs" text NULL, "task_name" varchar(255) NULL, "date_created" datetime NOT NULL, "worker" varchar(100) NULL, "periodic_task_name" varchar(255) NULL);
|
||||
CREATE TABLE IF NOT EXISTS "human_resources_employee" ("contact_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "access_contact" ("person_ptr_id") DEFERRABLE INITIALLY DEFERRED, "employee_number" integer NOT NULL UNIQUE);
|
||||
CREATE TABLE IF NOT EXISTS "itam_device" ("model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "serial_number" varchar(50) NULL UNIQUE, "inventorydate" datetime NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "device_model_id" integer NULL REFERENCES "itam_devicemodel" ("id") DEFERRABLE INITIALLY DEFERRED, "device_type_id" integer NULL REFERENCES "itam_devicetype" ("id") DEFERRABLE INITIALLY DEFERRED, "config" text NULL CHECK ((JSON_VALID("config") OR "config" IS NULL)), "is_virtual" bool NOT NULL, "uuid" char(32) NULL UNIQUE);
|
||||
CREATE TABLE IF NOT EXISTS "itam_devicemodel" ("model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "manufacturer_id" integer NULL REFERENCES "core_manufacturer" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "itam_deviceoperatingsystem" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "version" varchar(15) NOT NULL, "device_id" integer NOT NULL UNIQUE REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "operating_system_version_id" integer NOT NULL REFERENCES "itam_operatingsystemversion" ("id") DEFERRABLE INITIALLY DEFERRED, "installdate" datetime NULL);
|
||||
CREATE TABLE IF NOT EXISTS "django_session" ("session_key" varchar(40) NOT NULL PRIMARY KEY, "session_data" text NOT NULL, "expire_date" datetime NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_association" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "server_url" varchar(255) NOT NULL, "handle" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "issued" integer NOT NULL, "lifetime" integer NOT NULL, "assoc_type" varchar(64) NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_code" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "email" varchar(254) NOT NULL, "code" varchar(32) NOT NULL, "verified" bool NOT NULL, "timestamp" datetime NOT NULL);
|
||||
@ -200,7 +200,7 @@ CREATE TABLE IF NOT EXISTS "social_auth_nonce" ("id" integer NOT NULL PRIMARY KE
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_usersocialauth" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "provider" varchar(32) NOT NULL, "uid" varchar(255) NOT NULL, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "created" datetime NOT NULL, "modified" datetime NOT NULL, "extra_data" text NOT NULL CHECK ((JSON_VALID("extra_data") OR "extra_data" IS NULL)));
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_partial" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "token" varchar(32) NOT NULL, "next_step" smallint unsigned NOT NULL CHECK ("next_step" >= 0), "backend" varchar(32) NOT NULL, "timestamp" datetime NOT NULL, "data" text NOT NULL CHECK ((JSON_VALID("data") OR "data" IS NULL)));
|
||||
DELETE FROM sqlite_sequence;
|
||||
INSERT INTO sqlite_sequence VALUES('django_migrations',198);
|
||||
INSERT INTO sqlite_sequence VALUES('django_migrations',200);
|
||||
INSERT INTO sqlite_sequence VALUES('django_content_type',179);
|
||||
INSERT INTO sqlite_sequence VALUES('auth_permission',761);
|
||||
INSERT INTO sqlite_sequence VALUES('auth_group',0);
|
||||
@ -223,7 +223,6 @@ INSERT INTO sqlite_sequence VALUES('itam_operatingsystem',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_operatingsystemversion',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_softwarecategory',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_softwareversion',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_deviceoperatingsystem',0);
|
||||
INSERT INTO sqlite_sequence VALUES('settings_externallink',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_software',0);
|
||||
INSERT INTO sqlite_sequence VALUES('settings_usersettings',0);
|
||||
@ -243,7 +242,6 @@ INSERT INTO sqlite_sequence VALUES('assistance_knowledgebase',0);
|
||||
INSERT INTO sqlite_sequence VALUES('assistance_knowledgebasecategory_target_team',0);
|
||||
INSERT INTO sqlite_sequence VALUES('assistance_knowledgebasecategory',0);
|
||||
INSERT INTO sqlite_sequence VALUES('assistance_modelknowledgebasearticle',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_devicemodel',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_devicetype',0);
|
||||
INSERT INTO sqlite_sequence VALUES('config_management_configgrouphosts',0);
|
||||
INSERT INTO sqlite_sequence VALUES('config_management_configgroups',0);
|
||||
@ -254,6 +252,8 @@ INSERT INTO sqlite_sequence VALUES('devops_gitrepository',0);
|
||||
INSERT INTO sqlite_sequence VALUES('django_celery_results_chordcounter',0);
|
||||
INSERT INTO sqlite_sequence VALUES('django_celery_results_taskresult',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_device',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_devicemodel',0);
|
||||
INSERT INTO sqlite_sequence VALUES('itam_deviceoperatingsystem',0);
|
||||
INSERT INTO sqlite_sequence VALUES('social_auth_association',0);
|
||||
INSERT INTO sqlite_sequence VALUES('social_auth_code',0);
|
||||
INSERT INTO sqlite_sequence VALUES('social_auth_nonce',0);
|
||||
|
19
app/itam/tests/unit/device_operating_system/conftest.py
Normal file
19
app/itam/tests/unit/device_operating_system/conftest.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model(model_deviceoperatingsystem):
|
||||
|
||||
yield model_deviceoperatingsystem
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class', autouse = True)
|
||||
def model_kwargs(request, kwargs_deviceoperatingsystem):
|
||||
|
||||
request.cls.kwargs_create_item = kwargs_deviceoperatingsystem.copy()
|
||||
|
||||
yield kwargs_deviceoperatingsystem.copy()
|
||||
|
||||
if hasattr(request.cls, 'kwargs_create_item'):
|
||||
del request.cls.kwargs_create_item
|
@ -1,6 +1,5 @@
|
||||
import django
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
@ -24,6 +23,8 @@ User = django.contrib.auth.get_user_model()
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_deviceoperatingsystem
|
||||
@pytest.mark.module_itam
|
||||
class DeviceOperatingSystemAPI(
|
||||
TestCase,
|
||||
APITenancyObject
|
||||
@ -140,7 +141,7 @@ class DeviceOperatingSystemAPI(
|
||||
)
|
||||
|
||||
client = Client()
|
||||
url = reverse('v2:_api_device_operating_system-detail', kwargs=self.url_view_kwargs)
|
||||
url = reverse('v2:_api_deviceoperatingsystem-detail', kwargs=self.url_view_kwargs)
|
||||
|
||||
|
||||
client.force_login(self.view_user)
|
@ -0,0 +1,127 @@
|
||||
import pytest
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
from core.tests.unit.centurion_abstract.test_unit_centurion_abstract_model import (
|
||||
CenturionAbstractModelInheritedCases
|
||||
)
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_deviceoperatingsystem
|
||||
class DeviceOperatingSystemModelTestCases(
|
||||
CenturionAbstractModelInheritedCases
|
||||
):
|
||||
|
||||
|
||||
@property
|
||||
def parameterized_class_attributes(self):
|
||||
|
||||
return {
|
||||
'_audit_enabled': {
|
||||
'value': models.fields.NOT_PROVIDED
|
||||
},
|
||||
'_notes_enabled': {
|
||||
'value': models.fields.NOT_PROVIDED
|
||||
},
|
||||
'model_tag': {
|
||||
'type': models.fields.NOT_PROVIDED,
|
||||
'value': models.fields.NOT_PROVIDED
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@property
|
||||
def parameterized_model_fields(self):
|
||||
|
||||
return {
|
||||
'model_notes': {
|
||||
'blank': models.fields.NOT_PROVIDED,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.fields.NOT_PROVIDED,
|
||||
'null': models.fields.NOT_PROVIDED,
|
||||
'unique': models.fields.NOT_PROVIDED,
|
||||
},
|
||||
'device': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': False,
|
||||
'unique': True,
|
||||
},
|
||||
'operating_system_version': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
'version': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.CharField,
|
||||
'length': 15,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
'installdate': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.DateTimeField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'modified': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.DateTimeField,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
class DeviceOperatingSystemModelInheritedCases(
|
||||
DeviceOperatingSystemModelTestCases,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.module_itam
|
||||
class DeviceOperatingSystemModelPyTest(
|
||||
DeviceOperatingSystemModelTestCases,
|
||||
):
|
||||
|
||||
def test_method_get_url_kwargs(self, mocker, model_instance, model_kwargs):
|
||||
"""Test Class Method
|
||||
|
||||
Ensure method `get_url_kwargs` returns the correct value.
|
||||
"""
|
||||
|
||||
|
||||
url = model_instance.get_url_kwargs()
|
||||
|
||||
assert model_instance.get_url_kwargs() == {
|
||||
'device_id': model_kwargs['device'].id,
|
||||
'pk': model_instance.id
|
||||
}
|
||||
|
||||
|
||||
def test_model_tag_defined(self, model):
|
||||
""" Model Tag
|
||||
|
||||
Ensure that the model has a tag defined.
|
||||
"""
|
||||
|
||||
pytest.xfail( reason = 'model does not require' )
|
||||
|
||||
|
||||
def test_method_value_not_default___str__(self, model, model_instance ):
|
||||
"""Test Method
|
||||
|
||||
Ensure method `__str__` does not return the default value.
|
||||
"""
|
||||
|
||||
pytest.xfail( reason = 'model does not require' )
|
@ -1,3 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from django.test import Client, TestCase
|
||||
|
||||
from rest_framework.reverse import reverse
|
||||
@ -9,6 +11,8 @@ from itam.viewsets.device_operating_system import ViewSet
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_deviceoperatingsystem
|
||||
@pytest.mark.module_itam
|
||||
class DeviceOperatingSystemViewsetList(
|
||||
ModelViewSetInheritedCases,
|
||||
TestCase,
|
||||
@ -16,7 +20,7 @@ class DeviceOperatingSystemViewsetList(
|
||||
|
||||
viewset = ViewSet
|
||||
|
||||
route_name = 'v2:_api_device_operating_system'
|
||||
route_name = 'v2:_api_deviceoperatingsystem'
|
||||
|
||||
|
||||
@classmethod
|
@ -1,74 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.tenant import Tenant as Organization
|
||||
|
||||
from centurion.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device import Device, DeviceOperatingSystem
|
||||
from itam.models.operating_system import OperatingSystem, OperatingSystemVersion
|
||||
|
||||
|
||||
|
||||
class DeviceOperatingSystemModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = DeviceOperatingSystem
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
""" Setup Test
|
||||
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = Device.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'device_name'
|
||||
)
|
||||
|
||||
os = OperatingSystem.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'os_name'
|
||||
)
|
||||
|
||||
os_version = OperatingSystemVersion.objects.create(
|
||||
name = "12",
|
||||
operating_system = os,
|
||||
organization = self.organization,
|
||||
)
|
||||
|
||||
|
||||
self.kwargs_item_create = {
|
||||
'operating_system_version': os_version,
|
||||
'device': self.parent_item
|
||||
}
|
||||
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
def test_model_has_property_parent_object(self):
|
||||
""" Check if model contains 'parent_object'
|
||||
|
||||
This is a required property for all models that have a parent
|
||||
"""
|
||||
|
||||
assert hasattr(self.model, 'parent_object')
|
||||
|
||||
|
||||
def test_model_property_parent_object_returns_object(self):
|
||||
""" Check if model contains 'parent_object'
|
||||
|
||||
This is a required property for all models that have a parent
|
||||
"""
|
||||
|
||||
assert self.item.parent_object == self.parent_item
|
15
app/tests/fixtures/__init__.py
vendored
15
app/tests/fixtures/__init__.py
vendored
@ -72,6 +72,11 @@ from .model_devicemodel import (
|
||||
model_devicemodel,
|
||||
)
|
||||
|
||||
from .model_deviceoperatingsystem import (
|
||||
kwargs_deviceoperatingsystem,
|
||||
model_deviceoperatingsystem,
|
||||
)
|
||||
|
||||
from .model_devicetype import (
|
||||
kwargs_devicetype,
|
||||
model_devicetype,
|
||||
@ -129,6 +134,16 @@ from .model_manufacturer import (
|
||||
model_manufacturer,
|
||||
)
|
||||
|
||||
from .model_operatingsystem import (
|
||||
kwargs_operatingsystem,
|
||||
model_operatingsystem,
|
||||
)
|
||||
|
||||
from .model_operatingsystemversion import (
|
||||
kwargs_operatingsystemversion,
|
||||
model_operatingsystemversion,
|
||||
)
|
||||
|
||||
from .model_permission import (
|
||||
model_permission,
|
||||
)
|
||||
|
49
app/tests/fixtures/model_deviceoperatingsystem.py
vendored
Normal file
49
app/tests/fixtures/model_deviceoperatingsystem.py
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from itam.models.device import DeviceOperatingSystem
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model_deviceoperatingsystem():
|
||||
|
||||
yield DeviceOperatingSystem
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def kwargs_deviceoperatingsystem(django_db_blocker,
|
||||
kwargs_centurionmodel,
|
||||
kwargs_device, model_device,
|
||||
kwargs_operatingsystemversion, model_operatingsystemversion
|
||||
):
|
||||
|
||||
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
|
||||
random_str = str(random_str).replace(
|
||||
' ', '').replace(':', '').replace('+', '').replace('.', '')
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
device = model_device.objects.create(
|
||||
**kwargs_device.copy()
|
||||
)
|
||||
|
||||
operating_system_version = model_operatingsystemversion.objects.create(
|
||||
**kwargs_operatingsystemversion.copy()
|
||||
)
|
||||
|
||||
kwargs = {
|
||||
**kwargs_centurionmodel.copy(),
|
||||
'device': device,
|
||||
'operating_system_version': operating_system_version,
|
||||
'version': 'devos' + str(random_str)[len(str(random_str))-10:],
|
||||
'installdate': '2025-06-11T17:38:00Z',
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
device.delete()
|
||||
|
||||
operating_system_version.delete()
|
2
app/tests/fixtures/model_kwarg_data.py
vendored
2
app/tests/fixtures/model_kwarg_data.py
vendored
@ -45,6 +45,8 @@ def model_kwarg_data():
|
||||
elif(
|
||||
getattr(model, field).field.unique
|
||||
and not isinstance(getattr(model, field).field, models.UUIDField)
|
||||
and not isinstance(getattr(model, field).field, models.ForeignKey)
|
||||
|
||||
):
|
||||
|
||||
value = 'a' + random_str
|
||||
|
5
app/tests/fixtures/model_manufacturer.py
vendored
5
app/tests/fixtures/model_manufacturer.py
vendored
@ -15,11 +15,12 @@ def model_manufacturer():
|
||||
def kwargs_manufacturer(kwargs_centurionmodel):
|
||||
|
||||
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
|
||||
random_str = str(random_str).replace(
|
||||
' ', '').replace(':', '').replace('+', '').replace('.', '')
|
||||
|
||||
kwargs = {
|
||||
**kwargs_centurionmodel.copy(),
|
||||
'name': 'man' + str(random_str).replace(
|
||||
' ', '').replace(':', '').replace('+', '').replace('.', ''),
|
||||
'name': 'man' + random_str,
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
||||
|
38
app/tests/fixtures/model_operatingsystem.py
vendored
Normal file
38
app/tests/fixtures/model_operatingsystem.py
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from itam.models.operating_system import OperatingSystem
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model_operatingsystem():
|
||||
|
||||
yield OperatingSystem
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def kwargs_operatingsystem(django_db_blocker,
|
||||
kwargs_centurionmodel,
|
||||
kwargs_manufacturer, model_manufacturer,
|
||||
):
|
||||
|
||||
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
|
||||
random_str = str(random_str).replace(
|
||||
' ', '').replace(':', '').replace('+', '').replace('.', '')
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
publisher = model_manufacturer.objects.create( **kwargs_manufacturer.copy() )
|
||||
|
||||
kwargs = {
|
||||
**kwargs_centurionmodel.copy(),
|
||||
'name': 'os' + random_str,
|
||||
'publisher': publisher,
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
publisher.delete()
|
41
app/tests/fixtures/model_operatingsystemversion.py
vendored
Normal file
41
app/tests/fixtures/model_operatingsystemversion.py
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from itam.models.operating_system import OperatingSystemVersion
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model_operatingsystemversion():
|
||||
|
||||
yield OperatingSystemVersion
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def kwargs_operatingsystemversion(django_db_blocker,
|
||||
kwargs_centurionmodel,
|
||||
kwargs_operatingsystem, model_operatingsystem,
|
||||
):
|
||||
|
||||
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
|
||||
random_str = str(random_str).replace(
|
||||
' ', '').replace(':', '').replace('+', '').replace('.', '')
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
os = model_operatingsystem.objects.create(
|
||||
**kwargs_operatingsystem.copy()
|
||||
)
|
||||
|
||||
|
||||
kwargs = {
|
||||
**kwargs_centurionmodel.copy(),
|
||||
'operating_system': os,
|
||||
'name': 'osv' + random_str,
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
||||
|
||||
with django_db_blocker.unblock():
|
||||
|
||||
os.delete()
|
@ -1078,6 +1078,7 @@ markers = [
|
||||
"model_configgroupsoftware: Selects Config Group Software tests.",
|
||||
"model_device: Select all Device tests",
|
||||
"model_devicemodel: Select all device model tests.",
|
||||
"model_deviceoperatingsystem: Select tests for model Device Operating System",
|
||||
"model_devicetype: Select all device type tests.",
|
||||
"model_featureflag: Feature Flag Model",
|
||||
"model_gitgroup: Selects tests for model `git group`",
|
||||
@ -1087,6 +1088,8 @@ markers = [
|
||||
"model_knowledgebase: Selects Knowledge base tests.",
|
||||
"model_knowledgebasecategory: Selects Knowledge base category tests.",
|
||||
"model_manufacturer: Select all manufacturer tests.",
|
||||
"model_operatingsystem: Select tests for model Operating System",
|
||||
"model_operatingsystemversion: Select tests for model Operating System Version",
|
||||
"model_softwareenablefeatureflag: Selects tests for model Software Enabled Feature Flag.",
|
||||
"model_ticketcategory: Select all ticket category tests.",
|
||||
"model_ticketcommentcategory: Select all ticket comment category tests.",
|
||||
|
Reference in New Issue
Block a user