From 210517eeb1373c3aa91bdcfc0095352a5b335e6a Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Tue, 9 Jul 2019 14:37:25 -0400 Subject: [PATCH] Fix a couple of tests trivially affected by the upgrades - is_anonymous may no longer be called as a method, so no need to mock it - the message on uniqueness constraint failures has apparently changed --- awx/main/tests/functional/models/test_schedule.py | 2 +- awx/main/tests/unit/api/test_generics.py | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/awx/main/tests/functional/models/test_schedule.py b/awx/main/tests/functional/models/test_schedule.py index aee73e50eb..525fdd3022 100644 --- a/awx/main/tests/functional/models/test_schedule.py +++ b/awx/main/tests/functional/models/test_schedule.py @@ -457,4 +457,4 @@ def test_duplicate_name_within_template(job_template): with pytest.raises(IntegrityError) as ierror: s2.save() - assert str(ierror.value) == "columns unified_job_template_id, name are not unique" + assert str(ierror.value) == "UNIQUE constraint failed: main_schedule.unified_job_template_id, main_schedule.name" diff --git a/awx/main/tests/unit/api/test_generics.py b/awx/main/tests/unit/api/test_generics.py index de7f8ab4c8..caac45bc3b 100644 --- a/awx/main/tests/unit/api/test_generics.py +++ b/awx/main/tests/unit/api/test_generics.py @@ -186,11 +186,8 @@ class TestResourceAccessList: def mock_request(self): return mock.MagicMock( - user=mock.MagicMock( - is_anonymous=mock.MagicMock(return_value=False), - is_superuser=False - ), method='GET') - + user=mock.MagicMock(is_anonymous=False, is_superuser=False), + method='GET') def mock_view(self, parent=None): view = ResourceAccessList() @@ -200,7 +197,6 @@ class TestResourceAccessList: view.get_parent_object = lambda: parent return view - def test_parent_access_check_failed(self, mocker, mock_organization): mock_access = mocker.MagicMock(__name__='for logger', return_value=False) with mocker.patch('awx.main.access.BaseAccess.can_read', mock_access): @@ -208,7 +204,6 @@ class TestResourceAccessList: self.mock_view(parent=mock_organization).check_permissions(self.mock_request()) mock_access.assert_called_once_with(mock_organization) - def test_parent_access_check_worked(self, mocker, mock_organization): mock_access = mocker.MagicMock(__name__='for logger', return_value=True) with mocker.patch('awx.main.access.BaseAccess.can_read', mock_access):