refactor(project_management): Update Test Suite for Project model
ref: #824 #829
This commit is contained in:
@ -104,10 +104,10 @@ CREATE TABLE IF NOT EXISTS "devops_git_group_history" ("modelhistory_ptr_id" int
|
||||
CREATE TABLE IF NOT EXISTS "devops_github_repository_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_githubrepository" ("gitrepository_ptr_id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "devops_gitlab_repository_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_gitlabrepository" ("gitrepository_ptr_id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "devops_git_group_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_gitgroup" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "access_organization_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "access_organization_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "settings_usersettings" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "default_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "timezone" varchar(32) NOT NULL, "browser_mode" integer NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "access_organization_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "settings_appsettings" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "device_model_is_global" bool NOT NULL, "device_type_is_global" bool NOT NULL, "manufacturer_is_global" bool NOT NULL, "software_is_global" bool NOT NULL, "software_categories_is_global" bool NOT NULL, "global_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "owner_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
|
||||
CREATE TABLE IF NOT EXISTS "settings_usersettings" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "default_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "timezone" varchar(32) NOT NULL, "browser_mode" integer NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "access_company" ("entity_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED, "name" varchar(80) NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "access_entity" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "entity_type" varchar(30) NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "access_person" ("entity_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED, "f_name" varchar(64) NOT NULL, "l_name" varchar(64) NOT NULL, "dob" date NULL, "m_name" varchar(100) NULL);
|
||||
@ -234,8 +234,8 @@ INSERT INTO sqlite_sequence VALUES('core_ticket',0);
|
||||
INSERT INTO sqlite_sequence VALUES('core_ticketcomment',0);
|
||||
INSERT INTO sqlite_sequence VALUES('core_ticketlinkeditem',0);
|
||||
INSERT INTO sqlite_sequence VALUES('settings_externallink',0);
|
||||
INSERT INTO sqlite_sequence VALUES('settings_usersettings',0);
|
||||
INSERT INTO sqlite_sequence VALUES('settings_appsettings',1);
|
||||
INSERT INTO sqlite_sequence VALUES('settings_usersettings',0);
|
||||
INSERT INTO sqlite_sequence VALUES('access_entity',0);
|
||||
INSERT INTO sqlite_sequence VALUES('core_ticketbase',0);
|
||||
INSERT INTO sqlite_sequence VALUES('core_ticketcommentbase',0);
|
||||
|
19
app/project_management/tests/unit/project/conftest.py
Normal file
19
app/project_management/tests/unit/project/conftest.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model(model_project):
|
||||
|
||||
yield model_project
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class', autouse = True)
|
||||
def model_kwargs(request, kwargs_project):
|
||||
|
||||
request.cls.kwargs_create_item = kwargs_project.copy()
|
||||
|
||||
yield kwargs_project.copy()
|
||||
|
||||
if hasattr(request.cls, 'kwargs_create_item'):
|
||||
del request.cls.kwargs_create_item
|
@ -1,6 +1,5 @@
|
||||
import django
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
@ -15,10 +14,6 @@ from access.models.team_user import TeamUsers
|
||||
|
||||
from api.tests.abstract.api_fields import APITenancyObject
|
||||
|
||||
# from itam.models.device import Device
|
||||
|
||||
# from itim.models.clusters import Cluster, ClusterType
|
||||
|
||||
from project_management.models.projects import Project, ProjectState, ProjectType
|
||||
|
||||
from settings.models.user_settings import UserSettings
|
||||
@ -27,6 +22,8 @@ User = django.contrib.auth.get_user_model()
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_project
|
||||
@pytest.mark.module_project_management
|
||||
class ProjectAPI(
|
||||
TestCase,
|
||||
APITenancyObject
|
||||
|
@ -1,28 +1,178 @@
|
||||
import pytest
|
||||
|
||||
from django.test import TestCase
|
||||
from django.db import models
|
||||
|
||||
from centurion.tests.unit.test_unit_models import (
|
||||
TenancyObjectInheritedCases
|
||||
|
||||
from core.tests.unit.centurion_abstract.test_unit_centurion_abstract_model import (
|
||||
CenturionAbstractModelInheritedCases
|
||||
)
|
||||
|
||||
from project_management.models.projects import Project
|
||||
|
||||
|
||||
class ProjectModel(
|
||||
TenancyObjectInheritedCases,
|
||||
TestCase,
|
||||
|
||||
@pytest.mark.model_project
|
||||
class ClusterModelTestCases(
|
||||
CenturionAbstractModelInheritedCases
|
||||
):
|
||||
|
||||
model = Project
|
||||
|
||||
@property
|
||||
def parameterized_class_attributes(self):
|
||||
|
||||
return {
|
||||
'model_tag': {
|
||||
'type': str,
|
||||
'value': 'project'
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.skip( reason = 'to be written')
|
||||
def test_attribute_duration_ticket_value(self):
|
||||
"""Attribute value test
|
||||
@property
|
||||
def parameterized_model_fields(self):
|
||||
|
||||
This aattribute calculates the ticket duration from
|
||||
it's comments. must return total time in seconds
|
||||
"""
|
||||
return {
|
||||
'model_notes': {
|
||||
'blank': models.fields.NOT_PROVIDED,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.fields.NOT_PROVIDED,
|
||||
'null': models.fields.NOT_PROVIDED,
|
||||
'unique': models.fields.NOT_PROVIDED,
|
||||
},
|
||||
'external_ref': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.IntegerField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'external_system': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.IntegerField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'name': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.CharField,
|
||||
'length': 100,
|
||||
'null': False,
|
||||
'unique': True,
|
||||
},
|
||||
'description': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.TextField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'priority': {
|
||||
'blank': False,
|
||||
'default': Project.Priority.LOW,
|
||||
'field_type': models.IntegerField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'state': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'project_type': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'code': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.CharField,
|
||||
'length': 25,
|
||||
'null': True,
|
||||
'unique': True,
|
||||
},
|
||||
'planned_start_date': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.DateTimeField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'planned_finish_date': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.DateTimeField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'real_start_date': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.DateTimeField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'real_finish_date': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.DateTimeField,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'manager_user': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'manager_team': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': True,
|
||||
'unique': False,
|
||||
},
|
||||
'team_members': {
|
||||
'blank': True,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.ForeignKey,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
'is_deleted': {
|
||||
'blank': False,
|
||||
'default': False,
|
||||
'field_type': models.BooleanField,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
'modified': {
|
||||
'blank': False,
|
||||
'default': models.fields.NOT_PROVIDED,
|
||||
'field_type': models.DateTimeField,
|
||||
'null': False,
|
||||
'unique': False,
|
||||
},
|
||||
}
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class ClusterModelInheritedCases(
|
||||
ClusterModelTestCases,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_project_management
|
||||
class ClusterModelPyTest(
|
||||
ClusterModelTestCases,
|
||||
):
|
||||
pass
|
||||
|
@ -1,3 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from django.test import Client, TestCase
|
||||
|
||||
from rest_framework.reverse import reverse
|
||||
@ -8,6 +10,8 @@ from project_management.viewsets.project import ViewSet
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_project
|
||||
@pytest.mark.module_project_management
|
||||
class ProjectViewsetList(
|
||||
ModelViewSetInheritedCases,
|
||||
TestCase,
|
||||
|
5
app/tests/fixtures/__init__.py
vendored
5
app/tests/fixtures/__init__.py
vendored
@ -168,6 +168,11 @@ from .model_port import (
|
||||
model_port,
|
||||
)
|
||||
|
||||
from .model_project import (
|
||||
kwargs_project,
|
||||
model_project,
|
||||
)
|
||||
|
||||
from .model_service import (
|
||||
kwargs_service,
|
||||
model_service,
|
||||
|
27
app/tests/fixtures/model_project.py
vendored
Normal file
27
app/tests/fixtures/model_project.py
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from project_management.models.projects import Project
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model_project():
|
||||
|
||||
yield Project
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def kwargs_project(kwargs_centurionmodel):
|
||||
|
||||
random_str = str(datetime.datetime.now(tz=datetime.timezone.utc))
|
||||
random_str = str(random_str).replace(
|
||||
' ', '').replace(':', '').replace('+', '').replace('.', '')
|
||||
|
||||
kwargs = {
|
||||
**kwargs_centurionmodel.copy(),
|
||||
'name': 'project_' + random_str,
|
||||
'priority': Project.Priority.LOW,
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
@ -1094,6 +1094,7 @@ markers = [
|
||||
"model_operatingsystem: Select tests for model Operating System",
|
||||
"model_operatingsystemversion: Select tests for model Operating System Version",
|
||||
"model_port: Selects tests for model port",
|
||||
"model_project: Selects tests for model Project",
|
||||
"model_software: Selects tests for model Software.",
|
||||
"model_softwarecateory: Selects tests for model Software Category.",
|
||||
"model_softwareenablefeatureflag: Selects tests for model Software Enabled Feature Flag.",
|
||||
|
Reference in New Issue
Block a user