test: Migrate models to use refactored model tests
ref: #719 closes #708
This commit is contained in:
@ -27,7 +27,9 @@ class Team(Group, TenancyObject):
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
||||
|
||||
self.name = self.organization.name.lower().replace(' ', '_') + '_' + self.team_name.lower().replace(' ', '_')
|
||||
if self.organization_id:
|
||||
|
||||
self.name = self.organization.name.lower().replace(' ', '_') + '_' + self.team_name.lower().replace(' ', '_')
|
||||
|
||||
super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.contact import Contact
|
||||
from access.tests.unit.entity.test_unit_entity_viewset import (
|
||||
EntityViewsetInheritedCases
|
||||
from access.tests.unit.person.test_unit_person_viewset import (
|
||||
PersonViewsetInheritedCases
|
||||
)
|
||||
|
||||
|
||||
|
||||
class ViewsetTestCases(
|
||||
EntityViewsetInheritedCases,
|
||||
PersonViewsetInheritedCases,
|
||||
):
|
||||
|
||||
model: str = Contact
|
||||
|
@ -2,7 +2,10 @@ from django.test import TestCase
|
||||
|
||||
from access.models.entity import Entity
|
||||
|
||||
from app.tests.unit.test_unit_models import TenancyObjectInheritedCases
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,36 +1,17 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
# from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from access.models.organization_notes import OrganizationNotes
|
||||
|
||||
|
||||
|
||||
class OrganizationNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = OrganizationNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,38 +1,23 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.role import Role
|
||||
from access.models.organization import Organization
|
||||
from access.models.tenancy import TenancyObject
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
|
||||
|
||||
class ModelTestCases(
|
||||
TenancyModel,
|
||||
class RoleModelTestCases(
|
||||
TenancyObjectInheritedCases,
|
||||
):
|
||||
|
||||
model = None
|
||||
|
||||
kwargs_item_create: dict = None
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
different_organization = Organization.objects.create(name='test_different_organization')
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
model_notes = 'notes',
|
||||
**self.kwargs_item_create,
|
||||
)
|
||||
|
||||
|
||||
|
||||
def test_field_not_exists_is_global(self):
|
||||
def test_field_exist_is_global(self):
|
||||
"""Test model field not used
|
||||
|
||||
object must not be settable as a global object
|
||||
@ -44,18 +29,8 @@ class ModelTestCases(
|
||||
|
||||
|
||||
|
||||
def test_model_must_be_by_organization(self):
|
||||
"""Test model must be by organization
|
||||
|
||||
This model **must** be by organization.
|
||||
"""
|
||||
|
||||
assert issubclass(self.model, TenancyObject)
|
||||
|
||||
|
||||
|
||||
class RoleModelTest(
|
||||
ModelTestCases,
|
||||
RoleModelTestCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
|
@ -1,76 +1,32 @@
|
||||
import pytest
|
||||
import unittest
|
||||
from django.contrib.auth.models import GroupManager
|
||||
from django.test import TestCase
|
||||
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.test import TestCase, Client
|
||||
|
||||
from access.models.organization import Organization
|
||||
from access.models.team import Team
|
||||
from access.models.team_user import TeamUsers
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
|
||||
|
||||
class TeamModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
class ModelTestCases(
|
||||
TenancyObjectInheritedCases,
|
||||
):
|
||||
|
||||
manager = GroupManager
|
||||
|
||||
model = Team
|
||||
|
||||
kwargs_item_create = {
|
||||
'name': 'teamone'
|
||||
}
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
""" Setup Test
|
||||
|
||||
"""
|
||||
class TeamModelTest(
|
||||
ModelTestCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
self.parent_item = Organization.objects.create(name='test_org')
|
||||
|
||||
different_organization = Organization.objects.create(name='test_different_organization')
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=self.parent_item,
|
||||
name = 'teamone'
|
||||
)
|
||||
|
||||
|
||||
# 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 is self.parent_item
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_function_save_attributes():
|
||||
""" Ensure save Attributes function match django default
|
||||
|
||||
the save method is overridden. the function attributes must match default django method
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="uses Django group manager")
|
||||
def test_attribute_is_type_objects(self):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="uses Django group manager")
|
||||
def test_model_class_tenancy_manager_function_get_queryset_called(self):
|
||||
pass
|
||||
|
||||
|
||||
def test_model_fields_parameter_not_empty_help_text(self):
|
||||
@ -110,6 +66,7 @@ class TeamModel(
|
||||
|
||||
assert fields_have_test_value
|
||||
|
||||
|
||||
def test_model_fields_parameter_type_verbose_name(self):
|
||||
"""Test Field called with Parameter
|
||||
|
@ -1,37 +1,20 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from access.models.team_notes import TeamNotes
|
||||
|
||||
|
||||
|
||||
class TeamNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
kwargs_create_related_model = {
|
||||
'team_name': 'team one'
|
||||
}
|
||||
|
||||
model = TeamNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,22 +1,17 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase, Client
|
||||
from django.contrib.auth.models import Permission, User
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from access.models.organization import Organization
|
||||
from access.models.team import Team
|
||||
from access.models.team_user import TeamUsers
|
||||
|
||||
from app.tests.abstract.models import BaseModel
|
||||
|
||||
from core.mixin.history_save import SaveHistory
|
||||
from app.tests.unit.test_unit_models import NonTenancyObjectInheritedCases
|
||||
|
||||
|
||||
|
||||
class TeamUsersModel(
|
||||
NonTenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
BaseModel
|
||||
):
|
||||
|
||||
model = TeamUsers
|
||||
@ -25,25 +20,23 @@ class TeamUsersModel(
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
""" Setup Test
|
||||
""" Setup Test"""
|
||||
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
different_organization = Organization.objects.create(name='test_different_organization')
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.parent_item = Team.objects.create(
|
||||
team_name = 'test_team',
|
||||
organization = organization,
|
||||
organization = self.organization,
|
||||
)
|
||||
|
||||
team_user = User.objects.create_user(username="test_self.team_user", password="password")
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
team = self.parent_item,
|
||||
user = team_user
|
||||
)
|
||||
self.kwargs_item_create = {
|
||||
'team': self.parent_item,
|
||||
'user': team_user
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
@ -64,13 +57,3 @@ class TeamUsersModel(
|
||||
|
||||
assert self.item.parent_object == self.parent_item
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip( reason = 'TeamUsers is not a tenancy object' )
|
||||
def test_class_inherits_tenancy_objecy(self):
|
||||
""" Confirm class inheritence
|
||||
|
||||
TenancyObject must inherit TenancyObject
|
||||
"""
|
||||
|
||||
pass
|
@ -642,6 +642,7 @@ class TenancyObjectTest(
|
||||
verbose_name = 'Test Model'
|
||||
|
||||
|
||||
self.model = TestModel
|
||||
self.item = TestModel()
|
||||
|
||||
|
||||
@ -721,3 +722,29 @@ class TenancyObjectTest(
|
||||
"""
|
||||
|
||||
assert self.item.get_page_layout() is None
|
||||
|
||||
|
||||
def test_attribute_exists_table_fields(self):
|
||||
"""Attrribute Test, Exists
|
||||
|
||||
This test case is an override of a test with the same name. As this
|
||||
test suite is for testing the base object, the type returned must be
|
||||
None
|
||||
|
||||
Ensure attribute `table_fields` exists
|
||||
"""
|
||||
|
||||
assert not hasattr(self.item, 'table_fields')
|
||||
|
||||
|
||||
def test_attribute_type_table_fields(self):
|
||||
"""Attrribute Test, Type
|
||||
|
||||
This test case is an override of a test with the same name. As this
|
||||
test suite is for testing the base object, the type returned must be
|
||||
None
|
||||
|
||||
Ensure attribute `table_fields` is of type `list`
|
||||
"""
|
||||
|
||||
assert not hasattr(self.item, 'table_fields')
|
@ -5,7 +5,7 @@ from django.db.models import fields
|
||||
from rest_framework.exceptions import ValidationError
|
||||
|
||||
from access.models.organization import Organization
|
||||
from access.tests.unit.tenancy_object.test_unit_tenancy_object import (
|
||||
from access.tests.unit.tenancy_object.test_unit_tenancy_object_model import (
|
||||
TenancyObjectInheritedCases as AccessTenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
@ -300,23 +300,43 @@ class TenancyObjectInheritedCases(
|
||||
model = None
|
||||
|
||||
|
||||
kwargs_item_create: dict = {
|
||||
'name': 'one'
|
||||
}
|
||||
kwargs_item_create: dict = None
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
if not hasattr(self, 'organization'):
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.different_organization = Organization.objects.create(name='test_different_organization')
|
||||
|
||||
self.kwargs_item_create.update({
|
||||
'organization': self.organization,
|
||||
'model_notes': 'notes',
|
||||
})
|
||||
|
||||
if self.kwargs_item_create is None:
|
||||
|
||||
self.kwargs_item_create: dict = {}
|
||||
|
||||
|
||||
if 'name' in self.model().fields:
|
||||
|
||||
self.kwargs_item_create.update({
|
||||
'name': 'one'
|
||||
})
|
||||
|
||||
if 'organization' in self.model().fields:
|
||||
|
||||
self.kwargs_item_create.update({
|
||||
'organization': self.organization,
|
||||
})
|
||||
|
||||
if 'model_notes' in self.model().fields:
|
||||
|
||||
self.kwargs_item_create.update({
|
||||
'model_notes': 'notes',
|
||||
})
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
**self.kwargs_item_create,
|
||||
|
@ -1,44 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from assistance.models.knowledge_base import KnowledgeBase
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class KnowledgeBaseModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = KnowledgeBase
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
2. Create an item
|
||||
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
title = 'one',
|
||||
content = 'dict({"key": "one", "existing": "dont_over_write"})'
|
||||
)
|
||||
|
||||
self.second_item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
title = 'one_two',
|
||||
content = 'dict({"key": "two"})',
|
||||
)
|
@ -0,0 +1,21 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from assistance.models.knowledge_base import KnowledgeBase
|
||||
|
||||
|
||||
|
||||
class KnowledgeBaseModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
kwargs_item_create = {
|
||||
'title': 'one',
|
||||
'content': 'dict({"key": "one", "existing": "dont_over_write"})'
|
||||
}
|
||||
|
||||
model = KnowledgeBase
|
@ -1,42 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from assistance.models.knowledge_base import KnowledgeBaseCategory
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class KnowledgeBaseModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = KnowledgeBaseCategory
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
2. Create an item
|
||||
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
)
|
||||
|
||||
self.second_item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one_two',
|
||||
)
|
@ -0,0 +1,16 @@
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from assistance.models.knowledge_base import KnowledgeBaseCategory
|
||||
|
||||
|
||||
|
||||
class KnowledgeBaseModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = KnowledgeBaseCategory
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from assistance.models.knowledge_base_category_notes import KnowledgeCategoryBaseNotes
|
||||
|
||||
|
||||
|
||||
class KnowledgeCategoryBaseNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = KnowledgeCategoryBaseNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,38 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from assistance.models.knowledge_base_notes import KnowledgeBaseNotes
|
||||
|
||||
|
||||
|
||||
class KnowledgeBaseNotesNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = KnowledgeBaseNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
title = 'note model existing item',
|
||||
content = 'sadsadsad',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,11 +1,13 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from rest_framework.exceptions import ValidationError
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from assistance.models.model_knowledge_base_article import KnowledgeBase, ModelKnowledgeBaseArticle
|
||||
|
||||
@ -13,10 +15,9 @@ from itam.models.device import Device
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class ModelKnowledgeBaseArticleModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = ModelKnowledgeBaseArticle
|
||||
@ -35,12 +36,18 @@ class ModelKnowledgeBaseArticleModel(
|
||||
self.organization_two = Organization.objects.create(name='test_org_two')
|
||||
|
||||
knowledge_base = KnowledgeBase.objects.create(
|
||||
organization = self.organization_two,
|
||||
organization = self.organization,
|
||||
title = 'title',
|
||||
content = 'sdfsdf'
|
||||
)
|
||||
|
||||
knowledge_base_two = KnowledgeBase.objects.create(
|
||||
self.knowledge_base = KnowledgeBase.objects.create(
|
||||
organization = self.organization,
|
||||
title = 'title two',
|
||||
content = 'sdfsdfdsf'
|
||||
)
|
||||
|
||||
KnowledgeBase.objects.create(
|
||||
organization = self.organization_two,
|
||||
title = 'title two',
|
||||
content = 'sdfsdf'
|
||||
@ -52,17 +59,13 @@ class ModelKnowledgeBaseArticleModel(
|
||||
)
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
article = knowledge_base,
|
||||
model = str( self.device._meta.app_label ) + '.' + str( self.device._meta.model_name ),
|
||||
model_pk = self.device.id
|
||||
)
|
||||
self.kwargs_item_create = {
|
||||
'article': knowledge_base,
|
||||
'model': str( self.device._meta.app_label ) + '.' + str( self.device._meta.model_name ),
|
||||
'model_pk': self.device.id
|
||||
}
|
||||
|
||||
self.second_item = self.model.objects.create(
|
||||
article = knowledge_base_two,
|
||||
model = str( self.device._meta.app_label ) + '.' + str( self.device._meta.model_name ),
|
||||
model_pk = self.device.id
|
||||
)
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
@ -103,3 +106,35 @@ class ModelKnowledgeBaseArticleModel(
|
||||
|
||||
assert self.item.get_url() is None
|
||||
|
||||
|
||||
def test_create_validation_exception_no_organization(self):
|
||||
""" Tenancy objects must have an organization
|
||||
|
||||
This test case is a duplicate of a test with the same name. this
|
||||
model does not require this test as the org is derived from the model.org
|
||||
|
||||
Must not be able to create an item without an organization
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def test_create_no_validation_exception_organization_match_model(self):
|
||||
""" Tenancy objects must have an organization
|
||||
|
||||
Must not be able to create an item without an organization
|
||||
"""
|
||||
|
||||
kwargs_item_create = self.kwargs_item_create.copy()
|
||||
|
||||
kwargs_item_create.update({
|
||||
'article': self.knowledge_base
|
||||
})
|
||||
|
||||
del kwargs_item_create['organization']
|
||||
|
||||
article = self.model.objects.create(
|
||||
**kwargs_item_create,
|
||||
)
|
||||
|
||||
assert article.organization == self.organization
|
@ -10,8 +10,6 @@ from access.models.organization import Organization
|
||||
from access.models.team import Team
|
||||
from access.models.team_user import TeamUsers
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from config_management.models.groups import ConfigGroups
|
||||
|
||||
|
||||
|
@ -1,21 +1,25 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from config_management.models.groups import ConfigGroups
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class ConfigGroupsModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
kwargs_item_create = {
|
||||
'name': 'one',
|
||||
'config': dict({"key": "one", "existing": "dont_over_write"})
|
||||
}
|
||||
|
||||
model = ConfigGroups
|
||||
|
||||
@ -30,12 +34,8 @@ class ConfigGroupsModel(
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
config = dict({"key": "one", "existing": "dont_over_write"})
|
||||
)
|
||||
|
||||
self.second_item = self.model.objects.create(
|
||||
organization = self.organization,
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from config_management.models.config_group_notes import ConfigGroupNotes
|
||||
|
||||
|
||||
|
||||
class ConfigGroupNotesNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ConfigGroupNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,11 +1,10 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from config_management.models.groups import ConfigGroups, ConfigGroupSoftware
|
||||
|
||||
@ -15,8 +14,8 @@ from itam.models.software import Software
|
||||
|
||||
|
||||
class ConfigGroupSoftwareModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = ConfigGroupSoftware
|
||||
@ -28,25 +27,26 @@ class ConfigGroupSoftwareModel(
|
||||
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = ConfigGroups.objects.create(
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
name = 'group_one'
|
||||
)
|
||||
|
||||
self.software_item = Software.objects.create(
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
name = 'softwareone',
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = organization,
|
||||
software = self.software_item,
|
||||
config_group = self.parent_item,
|
||||
action = DeviceSoftware.Actions.INSTALL
|
||||
)
|
||||
self.kwargs_item_create = {
|
||||
'software': self.software_item,
|
||||
'config_group': self.parent_item,
|
||||
'action': DeviceSoftware.Actions.INSTALL
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from core.models.manufacturer import Manufacturer
|
||||
|
||||
|
||||
class ManufacturerModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = Manufacturer
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'man',
|
||||
)
|
@ -0,0 +1,27 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from core.models.manufacturer import Manufacturer
|
||||
|
||||
|
||||
class ManufacturerModelTestCases(
|
||||
TenancyObjectInheritedCases,
|
||||
):
|
||||
|
||||
kwargs_item_create = {
|
||||
'name': 'man'
|
||||
}
|
||||
|
||||
model = Manufacturer
|
||||
|
||||
|
||||
|
||||
class ManufacturerModelTest(
|
||||
ManufacturerModelTestCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
pass
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from core.models.manufacturer_notes import ManufacturerNotes
|
||||
|
||||
|
||||
|
||||
class ManufacturerNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ManufacturerNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -0,0 +1,89 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.unit.test_unit_models import TenancyObjectInheritedCases
|
||||
|
||||
from core.models.model_notes import ModelNotes
|
||||
|
||||
|
||||
|
||||
class ModelNotesTestCases(
|
||||
TenancyObjectInheritedCases
|
||||
):
|
||||
|
||||
model = ModelNotes
|
||||
|
||||
|
||||
|
||||
class ModelNotesInheritedCases(
|
||||
ModelNotesTestCases
|
||||
):
|
||||
|
||||
kwargs_item_create = None
|
||||
|
||||
|
||||
model = None
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
if not hasattr(self, 'organization'):
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
if not hasattr(self, 'kwargs_create_related_model'):
|
||||
|
||||
if 'organization' in self.model.model.field.related_model().fields:
|
||||
|
||||
self.kwargs_create_related_model: dict = {
|
||||
'organization': self.organization,
|
||||
}
|
||||
|
||||
else:
|
||||
|
||||
self.kwargs_create_related_model: dict = {}
|
||||
|
||||
|
||||
if 'organization' in self.model.model.field.related_model().fields:
|
||||
|
||||
self.kwargs_create_related_model.update({
|
||||
'organization': self.organization,
|
||||
})
|
||||
|
||||
|
||||
if 'name' in self.model.model.field.related_model().fields:
|
||||
|
||||
self.kwargs_create_related_model.update({
|
||||
'name': 'model for note'
|
||||
})
|
||||
|
||||
|
||||
|
||||
self.user = User.objects.create_user(username="test_user_view", password="password")
|
||||
|
||||
self.kwargs_item_create = {
|
||||
'content': 'a random comment for an exiting item',
|
||||
'content_type': ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
'model': self.model.model.field.related_model.objects.create(
|
||||
**self.kwargs_create_related_model,
|
||||
),
|
||||
'created_by': self.user,
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
class ModelNotesTest(
|
||||
ModelNotesTestCases
|
||||
):
|
||||
|
||||
pass
|
@ -3,19 +3,36 @@ from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import TenancyObjectInheritedCases
|
||||
|
||||
from core.models.manufacturer_history import Manufacturer, ManufacturerHistory
|
||||
from core.models.manufacturer_history import Manufacturer
|
||||
from core.models.model_history import ModelHistory
|
||||
|
||||
|
||||
class ManufacturerModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
|
||||
class ModelHistoryTestCases(
|
||||
TenancyObjectInheritedCases
|
||||
):
|
||||
|
||||
model = ModelHistory
|
||||
|
||||
should_model_history_be_saved = True
|
||||
|
||||
|
||||
|
||||
class ModelHistoryInheritedCases(
|
||||
ModelHistoryTestCases
|
||||
):
|
||||
|
||||
model = None
|
||||
|
||||
|
||||
|
||||
class ModelHistoryTest(
|
||||
ModelHistoryTestCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
should_model_history_be_saved = False
|
||||
|
||||
|
||||
@ -37,23 +54,42 @@ class ManufacturerModel(
|
||||
name = 'man',
|
||||
)
|
||||
|
||||
|
||||
self.history_entry = ManufacturerHistory.objects.create(
|
||||
organization = self.organization,
|
||||
action = self.model.Actions.ADD,
|
||||
user = User.objects.create_user(
|
||||
self.kwargs_item_create = {
|
||||
'action': self.model.Actions.ADD,
|
||||
'user': User.objects.create_user(
|
||||
username="test_user_view", password="password", is_superuser=True
|
||||
),
|
||||
before = {},
|
||||
after = {},
|
||||
content_type = ContentType.objects.get(
|
||||
'before': {},
|
||||
'after': {},
|
||||
'content_type': ContentType.objects.get(
|
||||
app_label = model._meta.app_label,
|
||||
model = model._meta.model_name,
|
||||
),
|
||||
model = model,
|
||||
)
|
||||
}
|
||||
|
||||
self.item = ModelHistory.objects.get(
|
||||
pk = self.history_entry.pk
|
||||
)
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
def test_attribute_type_get_url(self):
|
||||
"""Attribute Type
|
||||
|
||||
This test case is a duplicate test of a case with the same name.
|
||||
This model does not require this attribute.
|
||||
|
||||
get_url is of type str
|
||||
"""
|
||||
|
||||
assert not hasattr(self, 'item.get_url')
|
||||
|
||||
|
||||
def test_attribute_type_get_url_kwargs(self):
|
||||
"""Attribute Type
|
||||
|
||||
This test case is a duplicate test of a case with the same name.
|
||||
This model does not require this attribute.
|
||||
|
||||
get_url_kwargs is of type dict
|
||||
"""
|
||||
|
||||
assert not hasattr(self, 'item.get_url_kwargs')
|
||||
|
@ -1,20 +1,16 @@
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from core.models.ticket.ticket import Ticket
|
||||
|
||||
|
||||
class TicketModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = Ticket
|
||||
@ -38,19 +34,16 @@ class TicketModel(
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
self.add_user = User.objects.create_user(username="test_user_add", password="password")
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
title = 'A ticket',
|
||||
description = 'the ticket body',
|
||||
ticket_type = Ticket.TicketType.REQUEST,
|
||||
opened_by = self.add_user,
|
||||
status = int(Ticket.TicketStatus.All.NEW.value)
|
||||
)
|
||||
self.kwargs_item_create = {
|
||||
'title': 'A ticket',
|
||||
'description': 'the ticket body',
|
||||
'ticket_type': Ticket.TicketType.REQUEST,
|
||||
'opened_by': self.add_user,
|
||||
'status': int(Ticket.TicketStatus.All.NEW.value)
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
@ -1,51 +0,0 @@
|
||||
import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from core.models.ticket.ticket_category import TicketCategory
|
||||
|
||||
|
||||
class TicketCategoryModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = TicketCategory
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'cat',
|
||||
)
|
||||
|
||||
|
||||
# def test_attribute_duration_ticket_value(self):
|
||||
# """Attribute value test
|
||||
|
||||
# This aattribute calculates the ticket duration from
|
||||
# it's comments. must return total time in seconds
|
||||
# """
|
||||
|
||||
# pass
|
@ -0,0 +1,15 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from core.models.ticket.ticket_category import TicketCategory
|
||||
|
||||
|
||||
class TicketCategoryModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = TicketCategory
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from core.models.ticket.ticket_category_notes import TicketCategoryNotes
|
||||
|
||||
|
||||
|
||||
class NotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = TicketCategoryNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,20 +1,20 @@
|
||||
import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from core.models.ticket.ticket_comment import Ticket, TicketComment
|
||||
|
||||
|
||||
class TicketCommentModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = TicketComment
|
||||
@ -38,15 +38,13 @@ class TicketCommentModel(
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.add_user = User.objects.create_user(username="test_user_add", password="password")
|
||||
|
||||
|
||||
self.ticket = Ticket.objects.create(
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
title = 'A ticket',
|
||||
description = 'the ticket body',
|
||||
ticket_type = Ticket.TicketType.REQUEST,
|
||||
@ -54,11 +52,13 @@ class TicketCommentModel(
|
||||
status = int(Ticket.TicketStatus.All.NEW.value)
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
body = 'note',
|
||||
ticket = self.ticket,
|
||||
)
|
||||
self.kwargs_item_create = {
|
||||
'body': 'note',
|
||||
'ticket': self.ticket,
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
def test_attribute_duration_ticket_value(self):
|
||||
@ -68,4 +68,33 @@ class TicketCommentModel(
|
||||
it's comments. must return total time in seconds
|
||||
"""
|
||||
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
def test_create_validation_exception_no_organization(self):
|
||||
""" Tenancy objects must have an organization
|
||||
|
||||
This test case is a duplicate of a test with the same name. this
|
||||
model does not require this test as the org is derived from the ticket.org
|
||||
|
||||
Must not be able to create an item without an organization
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def test_create_no_exception_organization_match_ticket(self):
|
||||
""" organization must be same as ticket organization
|
||||
|
||||
during save, org is set from self.ticket.organization
|
||||
"""
|
||||
|
||||
kwargs_item_create = self.kwargs_item_create.copy()
|
||||
|
||||
del kwargs_item_create['organization']
|
||||
|
||||
comment = self.model.objects.create(
|
||||
**kwargs_item_create,
|
||||
)
|
||||
|
||||
assert comment.organization == comment.ticket.organization
|
@ -1,51 +0,0 @@
|
||||
import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from core.models.ticket.ticket_comment_category import TicketCommentCategory
|
||||
|
||||
|
||||
class TicketCommentCategoryModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = TicketCommentCategory
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'ticket cat',
|
||||
)
|
||||
|
||||
|
||||
# def test_attribute_duration_ticket_value(self):
|
||||
# """Attribute value test
|
||||
|
||||
# This aattribute calculates the ticket duration from
|
||||
# it's comments. must return total time in seconds
|
||||
# """
|
||||
|
||||
# pass
|
@ -0,0 +1,15 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from core.models.ticket.ticket_comment_category import TicketCommentCategory
|
||||
|
||||
|
||||
class TicketCommentCategoryModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = TicketCommentCategory
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from core.models.ticket.ticket_comment_category_notes import TicketCommentCategoryNotes
|
||||
|
||||
|
||||
|
||||
class NotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = TicketCommentCategoryNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import Client, TestCase
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
@ -2,7 +2,9 @@ from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from devops.models.check_ins import CheckIn
|
||||
|
||||
@ -11,7 +13,7 @@ from itam.models.software import Software
|
||||
|
||||
|
||||
class Model(
|
||||
TenancyModel,
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
@ -31,21 +33,21 @@ class Model(
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
software = Software.objects.create(
|
||||
self.kwargs_item_create = {
|
||||
'software': Software.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'soft',
|
||||
),
|
||||
version = '1.0',
|
||||
deployment_id = 'desc',
|
||||
feature = 'feature_flag',
|
||||
)
|
||||
'version': '1.0',
|
||||
'deployment_id': 'desc',
|
||||
'feature': 'feature_flag',
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
def test_attribute_not_empty_get_url(self):
|
||||
@ -70,3 +72,23 @@ class Model(
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def test_attribute_type_app_namespace(self):
|
||||
"""Attribute Type
|
||||
|
||||
app_namespace is of type str
|
||||
"""
|
||||
|
||||
assert type(self.model.app_namespace) is str
|
||||
|
||||
|
||||
def test_attribute_value_app_namespace(self):
|
||||
"""Attribute Type
|
||||
|
||||
app_namespace has been set, override this test case with the value
|
||||
of attribute `app_namespace`
|
||||
"""
|
||||
|
||||
assert self.model.app_namespace == 'devops'
|
||||
|
@ -2,7 +2,9 @@ from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from devops.models.feature_flag import FeatureFlag
|
||||
|
||||
@ -11,7 +13,7 @@ from itam.models.software import Software
|
||||
|
||||
|
||||
class Model(
|
||||
TenancyModel,
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
@ -29,19 +31,37 @@ class Model(
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
software = Software.objects.create(
|
||||
self.kwargs_item_create = {
|
||||
'name': 'one',
|
||||
'software': Software.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'soft',
|
||||
),
|
||||
description = 'desc',
|
||||
model_notes = 'text',
|
||||
enabled = True
|
||||
)
|
||||
'description': 'desc',
|
||||
'enabled': True
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
def test_attribute_type_app_namespace(self):
|
||||
"""Attribute Type
|
||||
|
||||
app_namespace is of type str
|
||||
"""
|
||||
|
||||
assert type(self.model.app_namespace) is str
|
||||
|
||||
|
||||
def test_attribute_value_app_namespace(self):
|
||||
"""Attribute Type
|
||||
|
||||
app_namespace has been set, override this test case with the value
|
||||
of attribute `app_namespace`
|
||||
"""
|
||||
|
||||
assert self.model.app_namespace == 'devops'
|
||||
|
@ -1,7 +1,10 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from access.models.organization import Organization
|
||||
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from devops.models.feature_flag_notes import FeatureFlagNotes
|
||||
from devops.models.software_enable_feature_flag import SoftwareEnableFeatureFlag
|
||||
@ -11,7 +14,7 @@ from itam.models.software import Software
|
||||
|
||||
|
||||
class FeatureFlagNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
@ -22,7 +25,8 @@ class FeatureFlagNotesModel(
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
software = Software.objects.create(
|
||||
organization = self.organization,
|
||||
@ -34,21 +38,32 @@ class FeatureFlagNotesModel(
|
||||
software = software,
|
||||
enabled = True
|
||||
)
|
||||
self.kwargs_create_related_model: dict = {
|
||||
'name': 'one',
|
||||
'software': software,
|
||||
'description': 'desc',
|
||||
'model_notes': 'text',
|
||||
'enabled': True
|
||||
}
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
software = software,
|
||||
description = 'desc',
|
||||
model_notes = 'text',
|
||||
enabled = True
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
||||
def test_attribute_type_app_namespace(self):
|
||||
"""Attribute Type
|
||||
|
||||
app_namespace is of type str
|
||||
"""
|
||||
|
||||
assert type(self.model.app_namespace) is str
|
||||
|
||||
|
||||
def test_attribute_value_app_namespace(self):
|
||||
"""Attribute Type
|
||||
|
||||
app_namespace has been set, override this test case with the value
|
||||
of attribute `app_namespace`
|
||||
"""
|
||||
|
||||
assert self.model.app_namespace == 'devops'
|
||||
|
@ -1,8 +1,10 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from devops.models.software_enable_feature_flag import SoftwareEnableFeatureFlag
|
||||
|
||||
@ -11,7 +13,7 @@ from itam.models.software import Software
|
||||
|
||||
|
||||
class Model(
|
||||
TenancyModel,
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
@ -30,19 +32,15 @@ class Model(
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
# name = 'one',
|
||||
software = Software.objects.create(
|
||||
self.kwargs_item_create = {
|
||||
'organization': self.organization,
|
||||
'software': Software.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'soft',
|
||||
),
|
||||
# description = 'desc',
|
||||
# model_notes = 'text',
|
||||
enabled = True
|
||||
)
|
||||
'enabled': True
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
@ -1,44 +1,22 @@
|
||||
# from django.conf import settings
|
||||
# from django.shortcuts import reverse
|
||||
from django.test import TestCase, Client
|
||||
from django.test import TestCase
|
||||
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device import Device
|
||||
|
||||
|
||||
class DeviceModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel,
|
||||
):
|
||||
|
||||
model = Device
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'deviceone'
|
||||
)
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_device_move_organization(user):
|
@ -1,45 +1,23 @@
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.test import TestCase, Client
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device_models import DeviceModel
|
||||
|
||||
|
||||
|
||||
class DeviceModelModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = DeviceModel
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'device model'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_device_model_software_action(user):
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device_model_notes import DeviceModelNotes
|
||||
|
||||
|
||||
|
||||
class DeviceModelNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = DeviceModelNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device_notes import DeviceNotes
|
||||
|
||||
|
||||
|
||||
class DeviceNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = DeviceNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,13 +1,10 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from config_management.models.groups import ConfigGroups, ConfigGroupSoftware
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device import Device, DeviceOperatingSystem
|
||||
from itam.models.operating_system import OperatingSystem, OperatingSystemVersion
|
||||
@ -15,8 +12,8 @@ from itam.models.operating_system import OperatingSystem, OperatingSystemVersion
|
||||
|
||||
|
||||
class DeviceOperatingSystemModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel,
|
||||
):
|
||||
|
||||
model = DeviceOperatingSystem
|
||||
@ -29,32 +26,33 @@ class DeviceOperatingSystemModel(
|
||||
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = Device.objects.create(
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
name = 'device_name'
|
||||
)
|
||||
|
||||
os = OperatingSystem.objects.create(
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
name = 'os_name'
|
||||
)
|
||||
|
||||
os_version = OperatingSystemVersion.objects.create(
|
||||
name = "12",
|
||||
operating_system = os,
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
)
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = organization,
|
||||
operating_system_version = os_version,
|
||||
device = self.parent_item
|
||||
)
|
||||
self.kwargs_item_create = {
|
||||
'operating_system_version': os_version,
|
||||
'device': self.parent_item
|
||||
}
|
||||
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
@ -1,13 +1,10 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from config_management.models.groups import ConfigGroups, ConfigGroupSoftware
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device import Device, DeviceSoftware
|
||||
from itam.models.software import Software
|
||||
@ -15,8 +12,8 @@ from itam.models.software import Software
|
||||
|
||||
|
||||
class DeviceSoftwareModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel,
|
||||
):
|
||||
|
||||
model = DeviceSoftware
|
||||
@ -28,24 +25,25 @@ class DeviceSoftwareModel(
|
||||
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = Device.objects.create(
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
name = 'device_name'
|
||||
)
|
||||
|
||||
self.software_item = Software.objects.create(
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
name = 'software_name',
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
software = self.software_item,
|
||||
device = self.parent_item,
|
||||
organization=organization,
|
||||
)
|
||||
self.kwargs_item_create = {
|
||||
'software': self.software_item,
|
||||
'device': self.parent_item,
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from itam.models.device import DeviceType
|
||||
|
||||
|
||||
class DeviceTypeModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = DeviceType
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'device type'
|
||||
)
|
@ -0,0 +1,15 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device import DeviceType
|
||||
|
||||
|
||||
class DeviceTypeModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = DeviceType
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.device_type_notes import DeviceTypeNotes
|
||||
|
||||
|
||||
|
||||
class DeviceTypeNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = DeviceTypeNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,53 +1,23 @@
|
||||
# from django.conf import settings
|
||||
# from django.shortcuts import reverse
|
||||
from django.test import TestCase, Client
|
||||
from django.test import TestCase
|
||||
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.operating_system import OperatingSystem
|
||||
|
||||
|
||||
|
||||
class OperatingSystemModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = OperatingSystem
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'os'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_operating_system_must_have_organization(user):
|
||||
""" Operating_system must have organization set """
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_operating_system_update_is_global_no_change(user):
|
||||
"""Once operating_system is set to global it can't be changed.
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.operating_system_notes import OperatingSystemNotes
|
||||
|
||||
|
||||
|
||||
class OperatingSystemNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = OperatingSystemNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,43 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from config_management.models.groups import ConfigGroups, ConfigGroupSoftware
|
||||
|
||||
from itam.models.operating_system import OperatingSystem, OperatingSystemVersion
|
||||
|
||||
|
||||
|
||||
class OperatingSystemVersionModel(
|
||||
TestCase,
|
||||
TenancyModel,
|
||||
):
|
||||
|
||||
model = OperatingSystemVersion
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
""" Setup Test
|
||||
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = OperatingSystem.objects.create(
|
||||
organization=organization,
|
||||
name = 'os_name'
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
name = "12",
|
||||
operating_system = self.parent_item,
|
||||
organization=organization,
|
||||
)
|
@ -0,0 +1,41 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
|
||||
from itam.models.operating_system import OperatingSystem, OperatingSystemVersion
|
||||
|
||||
|
||||
|
||||
class OperatingSystemVersionModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = OperatingSystemVersion
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
""" Setup Test
|
||||
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = OperatingSystem.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'os_name'
|
||||
)
|
||||
|
||||
self.kwargs_item_create = {
|
||||
'name': "12",
|
||||
'operating_system': self.parent_item,
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
@ -1,7 +1,10 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from access.models.organization import Organization
|
||||
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.operating_system import OperatingSystem
|
||||
from itam.models.operating_system_version_notes import OperatingSystemVersionNotes
|
||||
@ -9,7 +12,7 @@ from itam.models.operating_system_version_notes import OperatingSystemVersionNot
|
||||
|
||||
|
||||
class OperatingSystemVersionNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
@ -20,23 +23,15 @@ class OperatingSystemVersionNotesModel(
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
self.kwargs_create_related_model: dict = {
|
||||
'organization': self.organization,
|
||||
'name': 'note model existing item',
|
||||
'operating_system': OperatingSystem.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
operating_system = OperatingSystem.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'os'
|
||||
),
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
name = 'os'
|
||||
)
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
@ -1,67 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.test import TestCase, Client
|
||||
|
||||
from access.models.organization import Organization
|
||||
from access.models.team import Team
|
||||
from access.models.team_user import TeamUsers
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from itam.models.software import Software
|
||||
|
||||
|
||||
|
||||
class SoftwareModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = Software
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'software'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_software_must_have_organization(self):
|
||||
""" Software must have organization set """
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_software_update_is_global_no_change(self):
|
||||
"""Once software is set to global it can't be changed.
|
||||
|
||||
global status can't be changed as non-global items may reference the item.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_software_prevent_delete_if_used(self):
|
||||
"""Any software in use by a software must not be deleted.
|
||||
|
||||
i.e. A software has an action set for the software.
|
||||
"""
|
||||
|
||||
pass
|
43
app/itam/tests/unit/software/test_unit_software_model.py
Normal file
43
app/itam/tests/unit/software/test_unit_software_model.py
Normal file
@ -0,0 +1,43 @@
|
||||
import pytest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.software import Software
|
||||
|
||||
|
||||
|
||||
class SoftwareModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = Software
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_software_must_have_organization(self):
|
||||
""" Software must have organization set """
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_software_update_is_global_no_change(self):
|
||||
"""Once software is set to global it can't be changed.
|
||||
|
||||
global status can't be changed as non-global items may reference the item.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_software_prevent_delete_if_used(self):
|
||||
"""Any software in use by a software must not be deleted.
|
||||
|
||||
i.e. A software has an action set for the software.
|
||||
"""
|
||||
|
||||
pass
|
@ -1,41 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from itam.models.software import SoftwareCategory
|
||||
|
||||
|
||||
|
||||
class SoftwareCategoryModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = SoftwareCategory
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'software category',
|
||||
)
|
@ -0,0 +1,16 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.software import SoftwareCategory
|
||||
|
||||
|
||||
|
||||
class SoftwareCategoryModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = SoftwareCategory
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.software_category_notes import SoftwareCategoryNotes
|
||||
|
||||
|
||||
|
||||
class SoftwareCategoryNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = SoftwareCategoryNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,37 +1,17 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.software_notes import SoftwareNotes
|
||||
|
||||
|
||||
|
||||
class SoftwareNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases
|
||||
,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = SoftwareNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,20 +1,18 @@
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.software import Software, SoftwareVersion
|
||||
|
||||
|
||||
|
||||
class SoftwareVersionModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = SoftwareVersion
|
||||
@ -31,17 +29,16 @@ class SoftwareVersionModel(
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.software = Software.objects.create(
|
||||
organization=organization,
|
||||
organization = self.organization,
|
||||
name = 'deviceone'
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = '12',
|
||||
software = self.software
|
||||
)
|
||||
self.kwargs_item_create = {
|
||||
'name': '12',
|
||||
'software': self.software
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
@ -1,7 +1,11 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from access.models.organization import Organization
|
||||
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itam.models.software import Software
|
||||
from itam.models.software_version_notes import SoftwareVersionNotes
|
||||
@ -9,7 +13,7 @@ from itam.models.software_version_notes import SoftwareVersionNotes
|
||||
|
||||
|
||||
class SoftwareVersionNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
@ -20,23 +24,15 @@ class SoftwareVersionNotesModel(
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
self.kwargs_create_related_model: dict = {
|
||||
'organization': self.organization,
|
||||
'name': '11',
|
||||
'software': Software.objects.create(
|
||||
organization = self.organization,
|
||||
name = '11',
|
||||
software = Software.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'soft',
|
||||
),
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
name = 'soft',
|
||||
)
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
@ -1,42 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from itim.models.clusters import Cluster
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class ClusterModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = Cluster
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
2. Create an item
|
||||
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
)
|
||||
|
||||
self.second_item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one_two',
|
||||
)
|
16
app/itim/tests/unit/cluster/test_unit_cluster_model.py
Normal file
16
app/itim/tests/unit/cluster/test_unit_cluster_model.py
Normal file
@ -0,0 +1,16 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itim.models.clusters import Cluster
|
||||
|
||||
|
||||
|
||||
class ClusterModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = Cluster
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itim.models.cluster_notes import ClusterNotes
|
||||
|
||||
|
||||
|
||||
class ClusterNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ClusterNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itim.models.cluster_type_notes import ClusterTypeNotes
|
||||
|
||||
|
||||
|
||||
class ClusterTypeNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ClusterTypeNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,42 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from itim.models.clusters import ClusterType
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class ClusterTypeModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = ClusterType
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
2. Create an item
|
||||
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
)
|
||||
|
||||
self.second_item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one_two',
|
||||
)
|
@ -0,0 +1,16 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itim.models.clusters import ClusterType
|
||||
|
||||
|
||||
|
||||
class ClusterTypeModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ClusterType
|
@ -1,50 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from itim.models.services import Port
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class PortModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = Port
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
2. Create an item
|
||||
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
number = 1,
|
||||
)
|
||||
|
||||
self.second_item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
number = 2,
|
||||
)
|
||||
|
||||
@pytest.mark.skip(reason = 'to be written')
|
||||
def test_field_entry_invalid_port_to_high(self):
|
||||
"""Test Model Field
|
||||
|
||||
Ensure that a validation error is thrown and that is displays to the user
|
||||
"""
|
||||
pass
|
31
app/itim/tests/unit/port/test_unit_port_model.py
Normal file
31
app/itim/tests/unit/port/test_unit_port_model.py
Normal file
@ -0,0 +1,31 @@
|
||||
import pytest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itim.models.services import Port
|
||||
|
||||
|
||||
|
||||
class PortModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
kwargs_item_create = {
|
||||
'number': 1,
|
||||
}
|
||||
|
||||
model = Port
|
||||
|
||||
|
||||
@pytest.mark.skip(reason = 'to be written')
|
||||
def test_field_entry_invalid_port_to_high(self):
|
||||
"""Test Model Field
|
||||
|
||||
Ensure that a validation error is thrown and that is displays to the user
|
||||
"""
|
||||
pass
|
@ -1,17 +1,22 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from access.models.organization import Organization
|
||||
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itim.models.port_notes import PortNotes
|
||||
|
||||
|
||||
|
||||
class PortNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
|
||||
|
||||
model = PortNotes
|
||||
|
||||
|
||||
@ -19,19 +24,11 @@ class PortNotesModel(
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.kwargs_create_related_model: dict = {
|
||||
'organization': self.organization,
|
||||
'number': 22,
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
number = 22,
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,42 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from itim.models.services import Service
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class ServiceModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = Service
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
2. Create an item
|
||||
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
)
|
||||
|
||||
self.second_item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one_two',
|
||||
)
|
16
app/itim/tests/unit/service/test_unit_service_model.py
Normal file
16
app/itim/tests/unit/service/test_unit_service_model.py
Normal file
@ -0,0 +1,16 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from itim.models.services import Service
|
||||
|
||||
|
||||
|
||||
class ServiceModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = Service
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from itim.models.service_notes import ServiceNotes
|
||||
|
||||
|
||||
|
||||
class ServiceNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ServiceNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,51 +0,0 @@
|
||||
import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from project_management.models.projects import Project
|
||||
|
||||
|
||||
class ProjectModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = Project
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'proj model',
|
||||
)
|
||||
|
||||
|
||||
# def test_attribute_duration_ticket_value(self):
|
||||
# """Attribute value test
|
||||
|
||||
# This aattribute calculates the ticket duration from
|
||||
# it's comments. must return total time in seconds
|
||||
# """
|
||||
|
||||
# pass
|
@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.projects import Project
|
||||
|
||||
|
||||
class ProjectModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = Project
|
||||
|
||||
|
||||
@pytest.mark.skip( reason = 'to be written')
|
||||
def test_attribute_duration_ticket_value(self):
|
||||
"""Attribute value test
|
||||
|
||||
This aattribute calculates the ticket duration from
|
||||
it's comments. must return total time in seconds
|
||||
"""
|
||||
|
||||
pass
|
@ -1,56 +0,0 @@
|
||||
import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from project_management.models.project_milestone import Project, ProjectMilestone
|
||||
|
||||
|
||||
class ProjectMilestoneModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = ProjectMilestone
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
self.project = Project.objects.create(
|
||||
organization=organization,
|
||||
name = 'proj',
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'mile',
|
||||
project = self.project
|
||||
)
|
||||
|
||||
|
||||
# def test_attribute_duration_ticket_value(self):
|
||||
# """Attribute value test
|
||||
|
||||
# This aattribute calculates the ticket duration from
|
||||
# it's comments. must return total time in seconds
|
||||
# """
|
||||
|
||||
# pass
|
@ -0,0 +1,43 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.project_milestone import Project, ProjectMilestone
|
||||
|
||||
|
||||
class ProjectMilestoneModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ProjectMilestone
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.project = Project.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'proj',
|
||||
)
|
||||
|
||||
self.kwargs_item_create = {
|
||||
'name': 'mile',
|
||||
'project': self.project
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
@ -1,7 +1,10 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from access.models.organization import Organization
|
||||
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.projects import Project
|
||||
from project_management.models.project_milestone_notes import ProjectMilestoneNotes
|
||||
@ -9,7 +12,7 @@ from project_management.models.project_milestone_notes import ProjectMilestoneNo
|
||||
|
||||
|
||||
class ProjectMilestoneNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
@ -20,23 +23,15 @@ class ProjectMilestoneNotesModel(
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
self.organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
self.kwargs_create_related_model: dict = {
|
||||
'organization': self.organization,
|
||||
'name': 'note model existing item',
|
||||
'project': Project.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
project = Project.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
)
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
super().setUpTestData()
|
||||
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.project_notes import ProjectNotes
|
||||
|
||||
|
||||
|
||||
class ProjectNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ProjectNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,51 +0,0 @@
|
||||
import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from project_management.models.project_states import ProjectState
|
||||
|
||||
|
||||
class ProjectStateModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = ProjectState
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'state',
|
||||
)
|
||||
|
||||
|
||||
# def test_attribute_duration_ticket_value(self):
|
||||
# """Attribute value test
|
||||
|
||||
# This aattribute calculates the ticket duration from
|
||||
# it's comments. must return total time in seconds
|
||||
# """
|
||||
|
||||
# pass
|
@ -0,0 +1,15 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.project_states import ProjectState
|
||||
|
||||
|
||||
class ProjectStateModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ProjectState
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.project_state_notes import ProjectStateNotes
|
||||
|
||||
|
||||
|
||||
class ProjectStateNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ProjectStateNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,51 +0,0 @@
|
||||
import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from project_management.models.project_types import ProjectType
|
||||
|
||||
|
||||
class ProjectTypeModel(
|
||||
TestCase,
|
||||
TenancyModel
|
||||
):
|
||||
|
||||
model = ProjectType
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'type',
|
||||
)
|
||||
|
||||
|
||||
# def test_attribute_duration_ticket_value(self):
|
||||
# """Attribute value test
|
||||
|
||||
# This aattribute calculates the ticket duration from
|
||||
# it's comments. must return total time in seconds
|
||||
# """
|
||||
|
||||
# pass
|
@ -0,0 +1,15 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.project_types import ProjectType
|
||||
|
||||
|
||||
class ProjectTypeModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ProjectType
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.project_type_notes import ProjectTypeNotes
|
||||
|
||||
|
||||
|
||||
class ProjectTypeNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ProjectTypeNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
@ -1,41 +0,0 @@
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.test import TestCase, Client
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from app.tests.abstract.models import TenancyModel
|
||||
|
||||
from settings.models.external_link import ExternalLink
|
||||
|
||||
|
||||
|
||||
class ExternalLinkTests(
|
||||
TestCase,
|
||||
TenancyModel,
|
||||
):
|
||||
|
||||
model = ExternalLink
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
. create an organization that is different to item
|
||||
2. Create a device
|
||||
3. create teams with each permission: view, add, change, delete
|
||||
4. create a user per team
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
self.organization = organization
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization=organization,
|
||||
name = 'state',
|
||||
)
|
@ -0,0 +1,16 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from app.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
)
|
||||
|
||||
from settings.models.external_link import ExternalLink
|
||||
|
||||
|
||||
|
||||
class ExternalLinkTests(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ExternalLink
|
@ -1,37 +1,16 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_notes_model import ModelNotesModel
|
||||
from core.tests.unit.model_notes.test_unit_model_notes_model import (
|
||||
ModelNotesInheritedCases
|
||||
)
|
||||
|
||||
from settings.models.external_link_notes import ExternalLinkNotes
|
||||
|
||||
|
||||
|
||||
class ExternalLinkNotesModel(
|
||||
ModelNotesModel,
|
||||
ModelNotesInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
model = ExternalLinkNotes
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
content = 'a random comment for an exiting item',
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = str(self.model._meta.app_label).lower(),
|
||||
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
|
||||
),
|
||||
model = self.model.model.field.related_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'note model existing item',
|
||||
),
|
||||
created_by = self.user,
|
||||
)
|
||||
|
Reference in New Issue
Block a user