mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
Remove in-place operation on User in unit test
This commit is contained in:
@@ -28,12 +28,12 @@ class TestCustomInventoryScriptSerializer(object):
|
|||||||
(False, False, False, None)))
|
(False, False, False, None)))
|
||||||
def test_to_representation_orphan(self, superuser, sysaudit, admin_role, value):
|
def test_to_representation_orphan(self, superuser, sysaudit, admin_role, value):
|
||||||
with mock.patch.object(CustomInventoryScriptSerializer, 'get_summary_fields', return_value={}):
|
with mock.patch.object(CustomInventoryScriptSerializer, 'get_summary_fields', return_value={}):
|
||||||
User.add_to_class('is_system_auditor', sysaudit)
|
with mock.patch.object(User, 'is_system_auditor', return_value=sysaudit):
|
||||||
user = User(username="root", is_superuser=superuser)
|
user = User(username="root", is_superuser=superuser)
|
||||||
roles = [user] if admin_role else []
|
roles = [user] if admin_role else []
|
||||||
|
|
||||||
with mock.patch('awx.main.models.CustomInventoryScript.admin_role', new_callable=PropertyMock, return_value=roles):
|
with mock.patch('awx.main.models.CustomInventoryScript.admin_role', new_callable=PropertyMock, return_value=roles):
|
||||||
cis = CustomInventoryScript(pk=1, script='#!/python')
|
cis = CustomInventoryScript(pk=1, script=value)
|
||||||
serializer = CustomInventoryScriptSerializer()
|
serializer = CustomInventoryScriptSerializer()
|
||||||
|
|
||||||
factory = APIRequestFactory()
|
factory = APIRequestFactory()
|
||||||
|
|||||||
Reference in New Issue
Block a user