admin: add tests for binding creation forms with invalid target

This commit is contained in:
Jens Langhammer 2020-12-13 18:06:34 +01:00
parent 67925a39f2
commit 7ff7398aff
2 changed files with 16 additions and 2 deletions

View file

@ -1,4 +1,5 @@
"""admin tests"""
from uuid import uuid4
from django.test import TestCase
from django.test.client import RequestFactory
@ -18,7 +19,13 @@ class TestPolicyBindingView(TestCase):
view = PolicyBindingCreateView(request=request)
self.assertEqual(view.get_initial(), {})
def test_with_param(self):
def test_with_params_invalid(self):
"""Test PolicyBindingCreateView with invalid get params"""
request = self.factory.get("/", {"target": uuid4()})
view = PolicyBindingCreateView(request=request)
self.assertEqual(view.get_initial(), {})
def test_with_params(self):
"""Test PolicyBindingCreateView with get params"""
target = Application.objects.create(name="test")
request = self.factory.get("/", {"target": target.pk.hex})

View file

@ -1,4 +1,5 @@
"""admin tests"""
from uuid import uuid4
from django.test import TestCase
from django.test.client import RequestFactory
@ -18,7 +19,13 @@ class TestStageBindingView(TestCase):
view = StageBindingCreateView(request=request)
self.assertEqual(view.get_initial(), {})
def test_with_param(self):
def test_with_params_invalid(self):
"""Test StageBindingCreateView with invalid get params"""
request = self.factory.get("/", {"target": uuid4()})
view = StageBindingCreateView(request=request)
self.assertEqual(view.get_initial(), {})
def test_with_params(self):
"""Test StageBindingCreateView with get params"""
target = Flow.objects.create(name="test", slug="test")
request = self.factory.get("/", {"target": target.pk.hex})