refactor(accounting): Update existing tests to work due to model inheritance changes
ref: #862 #857
This commit is contained in:
@ -16,4 +16,7 @@ def model_kwargs(request, kwargs_assetbase):
|
||||
yield kwargs_assetbase.copy()
|
||||
|
||||
if hasattr(request.cls, 'kwargs_create_item'):
|
||||
del request.cls.kwargs_create_item
|
||||
try:
|
||||
del request.cls.kwargs_create_item
|
||||
except:
|
||||
pass
|
||||
|
@ -13,6 +13,10 @@ from accounting.viewsets.asset import (
|
||||
|
||||
from api.tests.unit.test_unit_common_viewset import SubModelViewSetInheritedCases
|
||||
|
||||
from centurion.tests.abstract.mock_view import MockRequest
|
||||
|
||||
from settings.models.app_settings import AppSettings
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_assetbase
|
||||
@ -46,7 +50,7 @@ class AssetBaseViewsetTestCases(
|
||||
if self.model is not AssetBase:
|
||||
|
||||
self.kwargs = {
|
||||
'asset_model': self.model._meta.sub_model_type
|
||||
'model_name': self.model._meta.sub_model_type
|
||||
}
|
||||
|
||||
self.viewset.kwargs = self.kwargs
|
||||
@ -63,6 +67,8 @@ class AssetBaseViewsetTestCases(
|
||||
|
||||
self.http_options_response_list = client.options(url)
|
||||
|
||||
a = 'a'
|
||||
|
||||
|
||||
|
||||
def test_view_attr_value_model_kwarg(self):
|
||||
@ -73,7 +79,30 @@ class AssetBaseViewsetTestCases(
|
||||
|
||||
view_set = self.viewset()
|
||||
|
||||
assert view_set.model_kwarg == 'asset_model'
|
||||
assert view_set.model_kwarg == 'model_name'
|
||||
|
||||
|
||||
|
||||
def test_view_attr_model_value(self):
|
||||
"""Attribute Test
|
||||
|
||||
Attribute `model` must return the correct sub-model
|
||||
"""
|
||||
|
||||
view_set = self.viewset()
|
||||
|
||||
|
||||
app_settings = AppSettings.objects.select_related('global_organization').get(
|
||||
owner_organization = None
|
||||
)
|
||||
|
||||
|
||||
view_set.request = MockRequest(
|
||||
user = self.view_user,
|
||||
app_settings = app_settings,
|
||||
)
|
||||
|
||||
assert view_set.model == self.model
|
||||
|
||||
|
||||
|
||||
|
@ -169,7 +169,7 @@ class APIFieldsTestCases:
|
||||
|
||||
view_team.permissions.set([view_permissions])
|
||||
|
||||
request.cls.view_user = User.objects.create_user(username="cafs_test_user_view" + str(random_str), password="password")
|
||||
request.cls.view_user = User.objects.create_user(username="cafs_test_user_view" + str(random_str), password="password", is_superuser = True)
|
||||
|
||||
team_user = TeamUsers.objects.create(
|
||||
team = view_team,
|
||||
|
Reference in New Issue
Block a user