Esempio n. 1
0
 def test_word_text_should_be_invalid(self):
     # Test that Word model text with spaces or non-letter characters
     # (other than hyphen) is invalid
     # This test could possibly be made more thorough
     invalid = ['a b', ' a', 'a ', '$', '%']
     for text in invalid:
         word = Word(text=text)
         with self.assertRaises(ValidationError):
             word.full_clean()
Esempio n. 2
0
 def test_word_text_should_be_valid(self):
     # Test that Word model text without spaces or non-letter characters
     # (other than hyphen) is invalid
     # This test could possibly be made more thorough
     valid = ['a', 'a-b', ur'\u00C0']
     for text in valid:
         word = Word(text=text)
         try:
             word.full_clean()
         except ValidationError:
             self.fail("Word#save raised ValidationError unexpectedly.")
Esempio n. 3
0
 def test_on_save_word_text_is_lowercased(self):
     # Test that Word model text is saved as lowercase
     word = Word(text='Hello')
     word.save()
     self.assertEqual(word.text, 'hello')