Esempio n. 1
0
 def test_form_validation_for_too_long_titles(self):
     form = LinkForm(data={'title': 'An unexpected failure—it’s actually in the tests for our final view, view_list. Because we’ve changed the way errors are displayed in all templates, we’re no longer showing the error that we manually pass into the template.', 'url': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.errors['title'],
         [TITLE_LENGTH_ERROR]
     )
Esempio n. 2
0
 def test_form_validation_for_too_long_titles(self):
     form = LinkForm(
         data={
             'title':
             'An unexpected failure—it’s actually in the tests for our final view, view_list. Because we’ve changed the way errors are displayed in all templates, we’re no longer showing the error that we manually pass into the template.',
             'url': ''
         })
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['title'], [TITLE_LENGTH_ERROR])
Esempio n. 3
0
 def test_form_validation_for_blank_titles_and_urls(self):
     form = LinkForm(data={'title': '', 'url': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.errors['title'],
         [TITLE_EMPTY_ERROR]
     )
     self.assertEqual(
         form.errors['url'],
         [URL_EMPTY_ERROR]
     )
Esempio n. 4
0
 def test_form_saves(self):
     #link = Link.objects.create()
     form = LinkForm(data={'title': 'poop', 'url': 'http://google.com/'})
     form.save()
     self.assertEqual(Link.objects.all().count(), 1)
Esempio n. 5
0
 def test_form_item_input_has_placeholder(self):
     form = LinkForm()
     self.assertIn('placeholder="Enter a descriptive title"', form.as_p())
Esempio n. 6
0
 def test_form_saves(self):
     #link = Link.objects.create()
     form = LinkForm(data={'title': 'poop', 'url': 'http://google.com/'})
     form.save()
     self.assertEqual(Link.objects.all().count(), 1)
Esempio n. 7
0
 def test_form_validation_for_blank_titles_and_urls(self):
     form = LinkForm(data={'title': '', 'url': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['title'], [TITLE_EMPTY_ERROR])
     self.assertEqual(form.errors['url'], [URL_EMPTY_ERROR])
Esempio n. 8
0
 def test_form_item_input_has_placeholder(self):
     form = LinkForm()
     self.assertIn('placeholder="Enter a descriptive title"', form.as_p())