mirror of
https://github.com/ansible/awx.git
synced 2026-03-23 20:05:03 -02:30
new view to allow associations but no creations
This commit is contained in:
@@ -11,7 +11,7 @@ from rest_framework.exceptions import PermissionDenied
|
||||
# AWX
|
||||
from awx.api.generics import (
|
||||
ParentMixin,
|
||||
SubListCreateAttachDetachAPIView,
|
||||
SubListCreateAttachDetachAPIView, SubListAttachDetachAPIView,
|
||||
DeleteLastUnattachLabelMixin,
|
||||
ResourceAccessList
|
||||
)
|
||||
@@ -140,6 +140,20 @@ class TestSubListCreateAttachDetachAPIView:
|
||||
view.unattach_by_id.assert_not_called()
|
||||
|
||||
|
||||
def test_attach_detatch_only(mocker):
|
||||
mock_request = mocker.MagicMock()
|
||||
mock_request.data = {'name': 'name for my new model'}
|
||||
view = SubListAttachDetachAPIView()
|
||||
view.model = mocker.MagicMock()
|
||||
view.model._meta = mocker.MagicMock()
|
||||
view.model._meta.verbose_name = "Foo Bar"
|
||||
|
||||
resp = view.post(mock_request)
|
||||
|
||||
assert 'Foo Bar' in resp.data['msg']
|
||||
assert 'field is missing' in resp.data['msg']
|
||||
|
||||
|
||||
class TestDeleteLastUnattachLabelMixin:
|
||||
@mock.patch('__builtin__.super')
|
||||
def test_unattach_ok(self, super, mocker):
|
||||
|
||||
Reference in New Issue
Block a user