Esempio n. 1
0
    def test_missing_text_is_invalid(self):
        form_data = {"title": "blah blah"}
        form = NewNoteForm(form_data)
        self.assertFalse(form.is_valid())

        invalid_texts = list(string.whitespace) + ['   ', '\n\n\n', '\t\t\n\t']

        for invalid_text in invalid_texts:
            form_data = {"title": "blah blah", "text": invalid_text}
            form = NewNoteForm(form_data)
            self.assertFalse(form.is_valid())
Esempio n. 2
0
    def test_missing_title_is_invalid(self):
        form_data = {'text': 'blah blah'}
        form = NewNoteForm(form_data)
        self.assertFalse(form.is_valid())

        invalid_titles = list(
            string.whitespace) + ['   ', '\n\n\n', '\t\t\n\t']

        for invalid_title in invalid_titles:
            form_data = {'title': invalid_title, 'text': 'blah blah'}
            form = NewNoteForm(form_data)
            self.assertFalse(form.is_valid())
Esempio n. 3
0
 def test_ok_title_and_length_is_valid(self):
     form_data = {
         "title": "blah blah",
         "text": "blah, blah, blah."
     }
     form = NewNoteForm(form_data)
     self.assertTrue(form.is_valid())
Esempio n. 4
0
 def test_text_too_long_is_invalid(self):
     # Max length is 1000
     form_data = {
         "title": "a" * 1001
     }
     form = NewNoteForm(form_data)
     self.assertFalse(form.is_valid())
Esempio n. 5
0
 def test_ok_title_and_length_is_valid(self):
     form_data = {
         'title': 'blah blah',
         'text': 'blah, blah, blah.',
         'rate': 'Great'
     }
     form = NewNoteForm(form_data)
     self.assertTrue(form.is_valid())
Esempio n. 6
0
 def test_ok_title_length_and_rating_is_valid(self):
     # Title and length is valid and rating is valid with values 1-5
     form_data = {
         "title": "blah blah",
         "text": "blah, blah, blah.",
         "rating": 5
     }
     form = NewNoteForm(form_data)
     self.assertTrue(form.is_valid())
Esempio n. 7
0
 def test_title_too_long_is_invalid(self):
     # Max length is 200
     form_data = {'title': 'a' * 201}
     form = NewNoteForm(form_data)
     self.assertFalse(form.is_valid())
Esempio n. 8
0
 def test_rating_greater_than_five_is_invalid(self):
     # Rating greater than five is invalid
     form_data = {"rating": 6}
     form = NewNoteForm(form_data)
     self.assertFalse(form.is_valid())
Esempio n. 9
0
 def test_rating_less_than_zero_is_invalid(self):
     # Rating less than zero is invalid
     form_data = {"rating": -1}
     form = NewNoteForm(form_data)
     self.assertFalse(form.is_valid())