test(core): Correct model notes test suite

ref: #731
This commit is contained in:
2025-04-22 22:22:58 +09:30
parent 0a630cf51a
commit 537f167b9e

View File

@ -1,5 +1,6 @@
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from access.models.organization import Organization
@ -13,15 +14,37 @@ class ModelNotesTestCases(
TenancyObjectInheritedCases
):
kwargs_item_create = {
'content': 'a random comment for an exiting item',
}
model = ModelNotes
@classmethod
def setUpTestData(self):
"""Setup Test"""
if not hasattr(self, 'organization'):
self.organization = Organization.objects.create(name='test_org')
self.user = User.objects.create_user(username="test_user_view", password="password")
self.kwargs_item_create.update({
'created_by': self.user,
})
super().setUpTestData()
class ModelNotesInheritedCases(
ModelNotesTestCases
):
kwargs_item_create = None
kwargs_item_create = {}
model = None
@ -31,6 +54,10 @@ class ModelNotesInheritedCases(
def setUpTestData(self):
"""Setup Test"""
kwargs_item_create = ModelNotesTestCases.kwargs_item_create
kwargs_item_create.update( self.kwargs_item_create )
if not hasattr(self, 'organization'):
self.organization = Organization.objects.create(name='test_org')
@ -62,12 +89,7 @@ class ModelNotesInheritedCases(
'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',
self.kwargs_item_create.update({
'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(),
@ -75,15 +97,38 @@ class ModelNotesInheritedCases(
'model': self.model.model.field.related_model.objects.create(
**self.kwargs_create_related_model,
),
'created_by': self.user,
}
})
super().setUpTestData()
class ModelNotesTest(
ModelNotesTestCases
ModelNotesTestCases,
TestCase
):
pass
@classmethod
def setUpTestData(self):
"""Setup Test"""
self.kwargs_item_create.update({
'content_type': ContentType.objects.get(
app_label = str(self.model._meta.app_label).lower(),
model = str(self.model._meta.model_name).lower(),
),
})
super().setUpTestData()
def test_attribute_type_get_url(self):
"""Attribute Type
This test case is a duplicate of a test with the same name. this model
does not require this attribute be tested as it's a base model.
get_url is of type str
"""
assert True