fix delete last label disassociate

* Inherit from mixin first in order to overwrite next inherited class
method, unattach.
* Also, fix up test and add test to ensure correct inheritance
This commit is contained in:
Chris Meyers
2016-06-29 16:46:13 -04:00
parent 6a6081dcf7
commit a57dca9786
4 changed files with 15 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ from django.contrib.contenttypes.models import ContentType
from awx.api.views import (
ApiV1RootView,
TeamRolesList,
JobTemplateLabelList,
)
from awx.main.models import (
@@ -62,6 +63,15 @@ class TestApiV1RootView:
for endpoint in endpoints:
assert endpoint in data_arg
class TestJobTemplateLabelList:
def test_inherited_mixin_unattach(self):
with mock.patch('awx.api.generics.DeleteLastUnattachLabelMixin.unattach') as mixin_unattach:
view = JobTemplateLabelList()
mock_request = mock.MagicMock()
super(JobTemplateLabelList, view).unattach(mock_request, None, None)
assert mixin_unattach.called_with(mock_request, None, None)
@pytest.mark.parametrize("url", ["/team/1/roles", "/role/1/teams"])
def test_team_roles_list_post_org_roles(url):
with mock.patch('awx.api.views.Role.objects.get') as role_get, \
@@ -84,3 +94,4 @@ def test_team_roles_list_post_org_roles(url):
assert response.status_code == 400
assert 'cannot assign' in response.content