1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

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
This commit is contained in:
Jeff Bradberry 2019-07-09 14:37:25 -04:00
parent 2ffe3d9a85
commit 210517eeb1
2 changed files with 3 additions and 8 deletions

View File

@ -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"

View File

@ -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):