예제 #1
0
 def test_correct_url_with_redirect(self):
     mtv = ModelToValidate(
         number=10,
         name='Some Name',
         url_verify='http://qa-dev.w3.org/link-testsuite/http.php?code=301'
     )  #example.com is a redirect to iana.org now
     self.assertEqual(None, mtv.full_clean()
                      )  # This will fail if there's no Internet connection
예제 #2
0
 def test_correct_https_url_but_nonexisting(self):
     mtv = ModelToValidate(number=10,
                           name='Some Name',
                           url_verify='https://www.example.com/')
     self.assertFieldFailsValidationWithMessage(
         mtv.full_clean, 'url_verify',
         [u'This URL appears to be a broken link.'])
예제 #3
0
 def test_correct_ftps_url_but_nonexisting(self):
     mtv = ModelToValidate(
         number=10,
         name='Some Name',
         url='ftps://ftp.google.com/we-love-microsoft.html')
     self.assertFieldFailsValidationWithMessage(
         mtv.full_clean, 'url', [u'This URL appears to be a broken link.'])
예제 #4
0
 def test_correct_url_but_nonexisting_gives_404(self):
     mtv = ModelToValidate(
         number=10,
         name='Some Name',
         url_verify='http://qa-dev.w3.org/link-testsuite/http.php?code=404')
     self.assertFieldFailsValidationWithMessage(
         mtv.full_clean, 'url_verify',
         [u'This URL appears to be a broken link.'])
예제 #5
0
 def test_correct_url_value_passes(self):
     mtv = ModelToValidate(number=10,
                           name='Some Name',
                           url='http://www.example.com/')
     self.assertEqual(None, mtv.full_clean()
                      )  # This will fail if there's no Internet connection
예제 #6
0
 def test_wrong_url_value_raises_error(self):
     mtv = ModelToValidate(number=10, name='Some Name', url='not a url')
     self.assertFieldFailsValidationWithMessage(mtv.full_clean, 'url',
                                                [u'Enter a valid value.'])
예제 #7
0
 def test_correct_email_value_passes(self):
     mtv = ModelToValidate(number=10,
                           name='Some Name',
                           email='*****@*****.**')
     self.assertEqual(None, mtv.full_clean())
예제 #8
0
 def test_wrong_email_value_raises_error(self):
     mtv = ModelToValidate(number=10,
                           name='Some Name',
                           email='not-an-email')
     self.assertFailsValidation(mtv.full_clean, ['email'])
예제 #9
0
파일: tests.py 프로젝트: ssaltzman/POET
 def test_correct_email_value_passes(self):
     mtv = ModelToValidate(number=10, name="Some Name", email="*****@*****.**")
     self.assertEqual(None, mtv.full_clean())
예제 #10
0
파일: tests.py 프로젝트: ssaltzman/POET
 def test_with_correct_value_model_validates(self):
     mtv = ModelToValidate(number=10, name="Some Name")
     self.assertEqual(None, mtv.full_clean())
예제 #11
0
 def test_custom_validate_method(self):
     mtv = ModelToValidate(number=11)
     self.assertFailsValidation(mtv.full_clean, [NON_FIELD_ERRORS, 'name'])
예제 #12
0
 def test_with_correct_value_model_validates(self):
     mtv = ModelToValidate(number=10, name='Some Name')
     self.assertEqual(None, mtv.full_clean())
예제 #13
0
 def test_missing_required_field_raises_error(self):
     mtv = ModelToValidate(f_with_custom_validator=42)
     self.assertFailsValidation(mtv.full_clean, ['name', 'number'])
예제 #14
0
파일: tests.py 프로젝트: mitsuhiko/django
 def test_correct_url_value_passes(self):
     mtv = ModelToValidate(number=10, name='Some Name', url='http://www.example.com/')
     self.assertEqual(None, mtv.full_clean()) # This will fail if there's no Internet connection
예제 #15
0
 def test_correct_url_with_redirect(self):
     mtv = ModelToValidate(number=10, name='Some Name', url_verify='http://qa-dev.w3.org/link-testsuite/http.php?code=301') #example.com is a redirect to iana.org now
     self.assertEqual(None, mtv.full_clean()) # This will fail if there's no Internet connection
예제 #16
0
 def test_text_greater_that_charfields_max_length_raises_erros(self):
     mtv = ModelToValidate(number=10, name='Some Name' * 100)
     self.assertFailsValidation(mtv.full_clean, [
         'name',
     ])
예제 #17
0
 def test_wrong_FK_value_raises_error(self):
     mtv = ModelToValidate(number=10, name='Some Name', parent_id=3)
     self.assertFailsValidation(mtv.full_clean, ['parent'])
예제 #18
0
파일: tests.py 프로젝트: ssaltzman/POET
 def test_correct_FK_value_validates(self):
     parent = ModelToValidate.objects.create(number=10, name="Some Name")
     mtv = ModelToValidate(number=10, name="Some Name", parent_id=parent.pk)
     self.assertEqual(None, mtv.full_clean())
예제 #19
0
 def test_correct_FK_value_validates(self):
     parent = ModelToValidate.objects.create(number=10, name='Some Name')
     mtv = ModelToValidate(number=10, name='Some Name', parent_id=parent.pk)
     self.assertEqual(None, mtv.full_clean())
예제 #20
0
파일: tests.py 프로젝트: ssaltzman/POET
 def test_correct_url_value_passes(self):
     mtv = ModelToValidate(number=10, name="Some Name", url="http://www.djangoproject.com/")
     self.assertEqual(None, mtv.full_clean())  # This will fail if there's no Internet connection
예제 #21
0
 def test_limited_FK_raises_error(self):
     # The limit_choices_to on the parent field says that a parent object's
     # number attribute must be 10, so this should fail validation.
     parent = ModelToValidate.objects.create(number=11, name='Other Name')
     mtv = ModelToValidate(number=10, name='Some Name', parent_id=parent.pk)
     self.assertFailsValidation(mtv.full_clean, ['parent'])