Ejemplo n.º 1
0
 def test_languages (self):
     self.assertEqual(len(self.ruleset.languages), 0)
     language1 = Language(self.ruleset, 'English')
     self.assertEqual(len(self.ruleset.languages), 1)
     self.assertTrue(language1 in self.ruleset.languages)
     language2 = Language(self.ruleset, 'German')
     self.assertEqual(len(self.ruleset.languages), 2)
     self.assertEqual(self.ruleset.languages, [language1, language2])
     language3 = Language(self.ruleset, 'Arabic')
     self.assertEqual(len(self.ruleset.languages), 3)
     self.assertEqual(self.ruleset.languages, [language3, language1,
                                               language2])
     language1.delete()
     self.assertEqual(len(self.ruleset.languages), 2)
     self.assertEqual(self.ruleset.languages, [language3, language2])
     language2.delete()
     language3.delete()
     self.assertEqual(len(self.ruleset.languages), 0)
Ejemplo n.º 2
0
 def test_invalid_name(self):
     language1 = Language(self.ruleset, 'English')
     self.assertRaises(IllegalArgumentError, Language, self.ruleset,
                       'English')
     language2 = Language(self.ruleset, 'German')
     self.assertRaises(IllegalArgumentError, setattr, language2, 'name',
                       'English')
     # Changing a name should make it possible for the old name to
     # be used by a different language.
     language2.name = 'French'
     language1.name = 'German'
     # A newly set name must also be unavalable to other languages.
     self.assertRaises(IllegalArgumentError, setattr, language2, 'name',
                       'German')
Ejemplo n.º 3
0
 def test_dates(self):
     language = Language(self.ruleset, 'English')
     self.assertEqual(len(language.dates), 0)
     date1 = Date(self.ruleset, 1, '1 A.D.')
     language.add_date(date1)
     self.assertEqual(language.dates, [date1])
     date2 = Date(self.ruleset, 2, '2 A.D.')
     language.add_date(date2)
     # Dates are ordered.
     self.assertEqual(language.dates, [date1, date2])
     date2.number = -1
     self.assertEqual(language.dates, [date2, date1])
     date2.delete()
     self.assertEqual(language.dates, [date1])
     date1.delete()
     self.assertEqual(len(language.dates), 0)
Ejemplo n.º 4
0
 def test_name(self):
     language = Language(self.ruleset, 'English')
     self.assertEqual(language.name, 'English')
     language.name = 'German'
     self.assertEqual(language.name, 'German')
Ejemplo n.º 5
0
 def test_languages(self):
     self.assertEqual(len(self.ruleset.languages), 0)
     language1 = Language(self.ruleset, 'English')
     self.assertEqual(len(self.ruleset.languages), 1)
     self.assertTrue(language1 in self.ruleset.languages)
     language2 = Language(self.ruleset, 'German')
     self.assertEqual(len(self.ruleset.languages), 2)
     self.assertEqual(self.ruleset.languages, [language1, language2])
     language3 = Language(self.ruleset, 'Arabic')
     self.assertEqual(len(self.ruleset.languages), 3)
     self.assertEqual(self.ruleset.languages,
                      [language3, language1, language2])
     language1.delete()
     self.assertEqual(len(self.ruleset.languages), 2)
     self.assertEqual(self.ruleset.languages, [language3, language2])
     language2.delete()
     language3.delete()
     self.assertEqual(len(self.ruleset.languages), 0)