mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 22:49:32 -02:30
Fix flake8 E302 errors.
This commit is contained in:
@@ -10,21 +10,25 @@ from rest_framework.response import Response
|
||||
# AWX
|
||||
from awx.api.generics import ParentMixin, SubListCreateAttachDetachAPIView, DeleteLastUnattachLabelMixin
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def get_object_or_404(mocker):
|
||||
# pytest patch without return_value generates a random value, we are counting on this
|
||||
return mocker.patch('awx.api.generics.get_object_or_404')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def get_object_or_400(mocker):
|
||||
return mocker.patch('awx.api.generics.get_object_or_400')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_response_new(mocker):
|
||||
m = mocker.patch('awx.api.generics.Response.__new__')
|
||||
m.return_value = m
|
||||
return m
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def parent_relationship_factory(mocker):
|
||||
def rf(serializer_class, relationship_name, relationship_value=mocker.Mock()):
|
||||
@@ -38,6 +42,7 @@ def parent_relationship_factory(mocker):
|
||||
return (serializer, mock_parent_relationship)
|
||||
return rf
|
||||
|
||||
|
||||
# TODO: Test create and associate failure (i.e. id doesn't exist, record already exists, permission denied)
|
||||
# TODO: Mock and check return (Response)
|
||||
class TestSubListCreateAttachDetachAPIView:
|
||||
@@ -122,6 +127,7 @@ class TestSubListCreateAttachDetachAPIView:
|
||||
view.unattach_validate.assert_called_with(mock_request)
|
||||
view.unattach_by_id.assert_not_called()
|
||||
|
||||
|
||||
class TestDeleteLastUnattachLabelMixin:
|
||||
@mock.patch('__builtin__.super')
|
||||
def test_unattach_ok(self, super, mocker):
|
||||
@@ -159,6 +165,7 @@ class TestDeleteLastUnattachLabelMixin:
|
||||
super.unattach_validate.assert_called_with(mock_request)
|
||||
assert mock_response == res
|
||||
|
||||
|
||||
class TestParentMixin:
|
||||
def test_get_parent_object(self, mocker, get_object_or_404):
|
||||
parent_mixin = ParentMixin()
|
||||
@@ -168,7 +175,6 @@ class TestParentMixin:
|
||||
mock_parent_mixin = mocker.MagicMock(wraps=parent_mixin)
|
||||
|
||||
return_value = mock_parent_mixin.get_parent_object()
|
||||
|
||||
|
||||
get_object_or_404.assert_called_with(parent_mixin.parent_model, **parent_mixin.kwargs)
|
||||
assert get_object_or_404.return_value == return_value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user