Skip to content

Commit ef5f913

Browse files
committed
test(settings): Remove old API Permission tests no longer required
ref: #833 #836
1 parent 43e89aa commit ef5f913

2 files changed

Lines changed: 101 additions & 84 deletions

File tree

app/settings/tests/functional/user_settings/test_user_settings_viewset.py

Lines changed: 82 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
from django.contrib.auth.models import Permission
55
from django.contrib.contenttypes.models import ContentType
6-
from django.shortcuts import reverse
7-
from django.test import Client, TestCase
8-
from django import urls
6+
7+
from django.test import TestCase
8+
# from django import urls
99

1010
from access.models.tenant import Tenant as Organization
1111
from access.models.team import Team
1212
from access.models.team_user import TeamUsers
1313

14-
from api.tests.abstract.api_permissions_viewset import (
15-
APIPermissionChange,
16-
APIPermissionView
17-
)
14+
# from api.tests.abstract.api_permissions_viewset import (
15+
# APIPermissionChange,
16+
# APIPermissionView
17+
# )
1818
from api.tests.abstract.api_serializer_viewset import (
1919
SerializerChange,
2020
SerializerView,
@@ -31,6 +31,9 @@
3131

3232

3333

34+
@pytest.mark.functional
35+
@pytest.mark.model_usersettings
36+
@pytest.mark.module_settings
3437
class ViewSetBase:
3538

3639
model = UserSettings
@@ -195,128 +198,128 @@ def setUpTestData(self):
195198

196199

197200

198-
class UserSettingsPermissionsAPI(
199-
ViewSetBase,
200-
APIPermissionChange,
201-
APIPermissionView,
202-
TestCase,
203-
):
201+
# class UserSettingsPermissionsAPI(
202+
# ViewSetBase,
203+
# APIPermissionChange,
204+
# APIPermissionView,
205+
# TestCase,
206+
# ):
204207

205208

206-
def test_returned_data_from_user_and_global_organizations_only(self):
207-
"""Check items returned
209+
# def test_returned_data_from_user_and_global_organizations_only(self):
210+
# """Check items returned
208211

209-
This test case is a over-ride of a test case with the same name.
210-
This model is not a tenancy model making this test not-applicable.
212+
# This test case is a over-ride of a test case with the same name.
213+
# This model is not a tenancy model making this test not-applicable.
211214

212-
Items returned from the query Must be from the users organization and
213-
global ONLY!
214-
"""
215-
pass
215+
# Items returned from the query Must be from the users organization and
216+
# global ONLY!
217+
# """
218+
# pass
216219

217220

218221

219-
def test_add_create_not_allowed(self):
220-
""" Check correct permission for add
222+
# # def test_add_create_not_allowed(self):
223+
# # """ Check correct permission for add
221224

222-
Not allowed to add.
223-
Ensure that the list view for HTTP/POST does not exist.
224-
"""
225+
# # Not allowed to add.
226+
# # Ensure that the list view for HTTP/POST does not exist.
227+
# # """
225228

226-
with pytest.raises(urls.exceptions.NoReverseMatch) as e:
229+
# # with pytest.raises(urls.exceptions.NoReverseMatch) as e:
227230

228-
url = reverse(self.app_namespace + ':' + self.url_name + '-list')
231+
# # url = reverse(self.app_namespace + ':' + self.url_name + '-list')
229232

230-
assert e.typename == 'NoReverseMatch'
233+
# # assert e.typename == 'NoReverseMatch'
231234

232235

233236

234-
def test_delete_has_permission(self):
235-
""" Check correct permission for delete
237+
# def test_delete_has_permission(self):
238+
# """ Check correct permission for delete
236239

237-
Delete item as user with delete permission
238-
"""
240+
# Delete item as user with delete permission
241+
# """
239242

240-
client = Client()
241-
url = reverse(self.app_namespace + ':' + self.url_name + '-detail', kwargs=self.url_view_kwargs)
243+
# client = Client()
244+
# url = reverse(self.app_namespace + ':' + self.url_name + '-detail', kwargs=self.url_view_kwargs)
242245

243246

244-
client.force_login(self.view_user)
245-
response = client.delete(url, data=self.delete_data)
247+
# client.force_login(self.view_user)
248+
# response = client.delete(url, data=self.delete_data)
246249

247-
assert response.status_code == 405
250+
# assert response.status_code == 405
248251

249252

250253

251-
def test_change_has_permission(self):
252-
""" Check correct permission for change
254+
# def test_change_has_permission(self):
255+
# """ Check correct permission for change
253256

254-
Make change with user who has change permission
255-
"""
257+
# Make change with user who has change permission
258+
# """
256259

257260

258-
item = self.model.objects.get( id = self.change_user.id )
261+
# item = self.model.objects.get( id = self.change_user.id )
259262

260-
item.default_organization = self.organization
263+
# item.default_organization = self.organization
261264

262-
item.save()
265+
# item.save()
263266

264-
client = Client()
265-
url = reverse(self.app_namespace + ':' + self.url_name + '-detail', kwargs={'pk': item.id})
267+
# client = Client()
268+
# url = reverse(self.app_namespace + ':' + self.url_name + '-detail', kwargs={'pk': item.id})
266269

267270

268-
client.force_login(self.change_user)
269-
response = client.patch(url, data={'different_organization': self.different_organization.id}, content_type='application/json')
271+
# client.force_login(self.change_user)
272+
# response = client.patch(url, data={'different_organization': self.different_organization.id}, content_type='application/json')
270273

271-
assert response.status_code == 200
274+
# assert response.status_code == 200
272275

273276

274-
def test_change_permission_view_denied(self):
275-
""" Ensure permission view cant make change
277+
# def test_change_permission_view_denied(self):
278+
# """ Ensure permission view cant make change
276279

277-
This test case is a duplicate of a test case with the same name.
278-
As this is the users own settings, any permission a user has will grant
279-
them access as user settings do not use permissions
280+
# This test case is a duplicate of a test case with the same name.
281+
# As this is the users own settings, any permission a user has will grant
282+
# them access as user settings do not use permissions
280283

281-
Attempt to make change as user with view permission
282-
"""
284+
# Attempt to make change as user with view permission
285+
# """
283286

284-
pass
287+
# pass
285288

286289

287-
def test_returned_results_only_user_orgs(self):
288-
"""Test not required
290+
# def test_returned_results_only_user_orgs(self):
291+
# """Test not required
289292

290-
this test is not required as this model is not a tenancy model
291-
"""
293+
# this test is not required as this model is not a tenancy model
294+
# """
292295

293-
pass
296+
# pass
294297

295298

296-
def test_change_no_permission_denied(self):
297-
""" Ensure permission view cant make change
299+
# def test_change_no_permission_denied(self):
300+
# """ Ensure permission view cant make change
298301

299-
This test case is a duplicate of a test case with the same name.
300-
This test is not required for this model as there are no permissions
301-
assosiated with accessing this model.
302+
# This test case is a duplicate of a test case with the same name.
303+
# This test is not required for this model as there are no permissions
304+
# assosiated with accessing this model.
302305

303-
Attempt to make change as user without permissions
304-
"""
306+
# Attempt to make change as user without permissions
307+
# """
305308

306-
pass
309+
# pass
307310

308311

309-
def test_view_no_permission_denied(self):
310-
""" Check correct permission for view
312+
# def test_view_no_permission_denied(self):
313+
# """ Check correct permission for view
311314

312-
This test case is a duplicate of a test case with the same name.
313-
This test is not required for this model as there are no permissions
314-
assosiated with accessing this model.
315+
# This test case is a duplicate of a test case with the same name.
316+
# This test is not required for this model as there are no permissions
317+
# assosiated with accessing this model.
315318

316-
Attempt to view with user missing permission
317-
"""
319+
# Attempt to view with user missing permission
320+
# """
318321

319-
pass
322+
# pass
320323

321324

322325

app/settings/tests/unit/user_settings/test_unit_user_settings_model.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import pytest
22

33
from django.db import models
4+
from django.urls import reverse
5+
from django.urls.exceptions import NoReverseMatch
46

57

68
from core.tests.unit.centurion_abstract.test_unit_centurion_abstract_model import (
@@ -12,7 +14,7 @@
1214

1315

1416
@pytest.mark.model_usersettings
15-
class AppSettingsModelTestCases(
17+
class UserSettingsModelTestCases(
1618
CenturionAbstractModelInheritedCases
1719
):
1820

@@ -91,17 +93,29 @@ def parameterized_model_fields(self):
9193
}
9294

9395

96+
def test_add_create_not_allowed(self, model):
97+
""" Check correct permission for add
9498
95-
class AppSettingsModelInheritedCases(
96-
AppSettingsModelTestCases,
99+
Not allowed to add.
100+
Ensure that the list view for HTTP/POST does not exist.
101+
"""
102+
103+
with pytest.raises( NoReverseMatch ) as e:
104+
105+
reverse('v2:' + model._meta.model_name + '-list')
106+
107+
108+
109+
class UserSettingsModelInheritedCases(
110+
UserSettingsModelTestCases,
97111
):
98112
pass
99113

100114

101115

102116
@pytest.mark.module_settings
103-
class AppSettingsModelPyTest(
104-
AppSettingsModelTestCases,
117+
class UserSettingsModelPyTest(
118+
UserSettingsModelTestCases,
105119
):
106120

107121
def test_model_tag_defined(self, model):

0 commit comments

Comments
 (0)