Skip to content

Commit

Permalink
test: Add Test case abstract classes to models
Browse files Browse the repository at this point in the history
!35 #46 #15
  • Loading branch information
jon-nfc committed Jul 13, 2024
1 parent e48278e commit f29ec63
Show file tree
Hide file tree
Showing 25 changed files with 814 additions and 2 deletions.
21 changes: 21 additions & 0 deletions app/access/tests/unit/organization/test_organization_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest
import unittest
import requests

from django.test import TestCase

from app.tests.abstract.models import ModelDisplay, ModelIndex



class OrganizationViews(
TestCase,
ModelDisplay,
ModelIndex
):

display_module = 'access.views.organization'
display_view = 'View'

index_module = display_module
index_view = 'IndexView'
29 changes: 29 additions & 0 deletions app/access/tests/unit/team/test_team_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
import unittest
import requests

from django.test import TestCase

from app.tests.abstract.models import ModelAdd, ModelDelete, ModelDisplay



class TeamViews(
TestCase,
ModelAdd,
ModelDelete,
ModelDisplay,
):

add_module = 'access.views.team'
add_view = 'Add'

# change_module = add_module
# change_view = 'Change'

delete_module = add_module
delete_view = 'Delete'

display_module = add_module
display_view = 'View'

30 changes: 30 additions & 0 deletions app/access/tests/unit/team_user/test_team_user_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest
import unittest
import requests

from django.test import TestCase

from app.tests.abstract.models import AddView, DeleteView



class TeamUserViews(
TestCase,
AddView,
DeleteView
):

add_module = 'access.views.user'
add_view = 'Add'

# change_module = add_module
# change_view = 'GroupView'

delete_module = add_module
delete_view = 'Delete'

# display_module = add_module
# display_view = 'GroupView'

# index_module = add_module
# index_view = 'GroupIndexView'
63 changes: 63 additions & 0 deletions app/app/tests/abstract/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import pytest
import unittest

from app.tests.abstract.views import AddView, ChangeView, DeleteView, DisplayView, IndexView

class ModelAdd(
AddView
):
""" Unit Tests for Model Add """



class ModelChange(
ChangeView
):
""" Unit Tests for Model Change """



class ModelDelete(
DeleteView
):
""" Unit Tests for Model delete """



class ModelDisplay(
DisplayView
):
""" Unit Tests for Model display """



class ModelIndex(
IndexView
):
""" Unit Tests for Model index """



class ModelCommon(
ModelAdd,
ModelChange,
ModelDelete,
ModelDisplay
):
""" Unit Tests for all models """



class PrimaryModel(
ModelCommon,
ModelIndex
):
""" Tests for Primary Models
A Primary model is a model that is deemed a model that has the following views:
- Add
- Change
- Delete
- Display
- Index
"""
99 changes: 99 additions & 0 deletions app/app/tests/abstract/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import pytest
import unittest



class AddView:
""" Testing of Display view """

add_module: str = None
""" Full module path to test """

add_view: str = None
""" View Class name to test """



class ChangeView:
""" Testing of Display view """

change_module: str = None
""" Full module path to test """

change_view: str = None
""" Change Class name to test """



class DeleteView:
""" Testing of Display view """

delete_module: str = None
""" Full module path to test """

delete_view: str = None
""" Delete Class name to test """



class DisplayView:
""" Testing of Display view """

display_module: str = None
""" Full module path to test """

display_view: str = None
""" Change Class name to test """



class IndexView:
""" Testing of Display view """

index_module: str = None
""" Full module path to test """

index_view: str = None
""" Index Class name to test """



class AllViews(
AddView,
ChangeView,
DeleteView,
DisplayView,
IndexView
):
""" Abstract test class containing ALL view tests """

add_module: str = None
""" Full module path to test """

add_view: str = None
""" View Class name to test """

change_module: str = None
""" Full module path to test """

change_view: str = None
""" Change Class name to test """

delete_module: str = None
""" Full module path to test """

delete_view: str = None
""" Delete Class name to test """

display_module: str = None
""" Full module path to test """

display_view: str = None
""" Change Class name to test """

index_module: str = None
""" Full module path to test """

index_view: str = None
""" Index Class name to test """

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
import unittest
import requests

from django.test import TestCase

from app.tests.abstract.models import PrimaryModel



class ConfigManagementViews(
TestCase,
PrimaryModel
):

add_module = 'config_management.views.groups.groups'
add_view = 'GroupAdd'

change_module = add_module
change_view = 'GroupView'

delete_module = add_module
delete_view = 'GroupDelete'

display_module = add_module
display_view = 'GroupView'

index_module = add_module
index_view = 'GroupIndexView'
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytest
import unittest
import requests

from django.test import TestCase

from app.tests.abstract.models import AddView, ChangeView, DeleteView



class ConfigGroupsSoftwareViews(
TestCase,
AddView,
ChangeView,
DeleteView
):

add_module = 'config_management.views.groups.software'
add_view = 'GroupSoftwareAdd'

change_module = add_module
change_view = 'GroupSoftwareChange'

delete_module = add_module
delete_view = 'GroupSoftwareDelete'

# display_module = add_module
# display_view = 'GroupView'

# index_module = add_module
# index_view = 'GroupIndexView'
29 changes: 29 additions & 0 deletions app/core/tests/unit/manufacturer/test_manufacturer_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
import unittest
import requests

from django.test import TestCase

from app.tests.abstract.models import PrimaryModel



class ManufacturerViews(
TestCase,
PrimaryModel
):

add_module = 'settings.views.manufacturer'
add_view = 'Add'

change_module = add_module
change_view = 'View'

delete_module = add_module
delete_view = 'Delete'

display_module = add_module
display_view = 'View'

index_module = add_module
index_view = 'Index'
35 changes: 35 additions & 0 deletions app/core/tests/unit/test_history/test_history_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pytest
import unittest
import requests

from django.test import TestCase

from app.tests.abstract.models import ModelDisplay



class HistoryViews(
TestCase,
ModelDisplay
):

# add_module = 'config_management.views.groups.groups'
# add_view = 'GroupAdd'

# change_module = add_module
# change_view = 'GroupView'

# delete_module = add_module
# delete_view = 'GroupDelete'

display_module = 'core.views.history'
display_view = 'View'

# index_module = add_module
# index_view = 'GroupIndexView'

@pytest.mark.skip(reason="test this models dynamic build of self.model")
def test_view_display_attribute_exists_model(self):
""" As part of display init this view dynamically builds self.model """

pass
Loading

0 comments on commit f29ec63

Please sign in to comment.