test clean() throws ValidationError
@@ -5,7 +5,7 @@ from unittest.mock import patch
import os
import random
-from django.contrib.auth.models import AnonymousUser
+from django.contrib.auth.models import AnonymousUser, User
from django.core.exceptions import ValidationError, PermissionDenied
from django.core.management import call_command
from django.core.urlresolvers import reverse
@@ -416,6 +416,7 @@ class PartnerModelTests(TestCase):
example_url = "https://www.example.com"
partner1.target_url = example_url
+ partner1.requested_access_duration = True # We don't want the ValidationError from requested_access_duration
partner1.save()
partner2.target_url = example_url
partner2.save()
@@ -426,6 +427,12 @@ class PartnerModelTests(TestCase):
self.assertIsNotNone(msg)
self.assertIn(partner2.company_name, msg)
+ self.assertRaises(ValidationError, partner1.clean)
+ try:
+ partner1.clean()
+ except ValidationError as e:
+ self.assertEqual([msg], e.messages)
+
stream1.target_url = example_url
stream1.save()
@@ -439,6 +446,17 @@ class PartnerModelTests(TestCase):
self.assertIn(partner1.company_name, msg)
self.assertIn(stream1.name, msg)
+ msg = check_for_target_url_duplication_and_generate_error_message(
+ stream1, stream=True
+ )
+
+ self.assertIsNotNone(msg)
+ self.assertRaises(ValidationError, stream1.clean)
+ try:
+ stream1.clean()
+ except ValidationError as e:
+ self.assertEqual([msg], e.messages)
+
class WaitlistBehaviorTests(TestCase):
"""
