def test_rejects_non_bugzilla_url(self): field = BugzillaURLField() with self.assertRaises(ValidationError): field.clean("www.example.com")
def test_accepts_bugzilla_url(self): field = BugzillaURLField() bugzilla_url = "{base}/show_bug.cgi?id=123".format( base=settings.BUGZILLA_HOST) cleaned = field.clean(bugzilla_url) self.assertEqual(cleaned, bugzilla_url)
def test_rejects_non_show_bug_bugzilla_url(self): field = BugzillaURLField() bugzilla_url = "{base}/123".format(base=settings.BUGZILLA_HOST) with self.assertRaises(ValidationError): field.clean(bugzilla_url)
def test_accepts_bugzilla_url(self): field = BugzillaURLField() bugzilla_url = "{base}/123/".format(base=field.BUGZILLA_BASE_URL) cleaned = field.clean(bugzilla_url) self.assertEqual(cleaned, bugzilla_url)