Exemplo n.º 1
0
    def test_logic(self):
        person = Person(name="Chris Beaven", country="NZ")

        self.assertEqual(person.country, "NZ")
        self.assertNotEqual(person.country, "ZZ")

        self.assertTrue(person.country)
        person.country = ""
        self.assertFalse(person.country)
Exemplo n.º 2
0
    def test_logic(self):
        person = Person(name='Chris Beaven', country='NZ')

        self.assertEqual(person.country, 'NZ')
        self.assertNotEqual(person.country, 'ZZ')

        self.assertTrue(person.country)
        person.country = ''
        self.assertFalse(person.country)
Exemplo n.º 3
0
 def test_name(self):
     person = Person(name='Chris Beaven', fantasy_country='NV')
     self.assertEqual(person.fantasy_country.name, 'Neverland')
Exemplo n.º 4
0
 def test_validate_empty(self):
     person = Person(name='Chris')
     self.assertRaises(validators.ValidationError, person.full_clean)
Exemplo n.º 5
0
 def test_validate_invalid(self):
     person = Person(name='Chris', country=':(')
     self.assertRaises(validators.ValidationError, person.full_clean)
Exemplo n.º 6
0
    def test_len(self):
        person = Person(name="Chris Beaven", country="NZ")
        self.assertEqual(len(person.country), 2)

        person = Person(name="The Outsider", country=None)
        self.assertEqual(len(person.country), 0)
Exemplo n.º 7
0
 def test_render_modelform_instance(self):
     person = Person(country="NZ")
     self.Form(instance=person).as_p()
Exemplo n.º 8
0
 def test_flag_css(self):
     person = Person(name='Chris Beaven', country='NZ')
     self.assertEqual(person.country.flag_css, 'flag-sprite flag-n flag-_z')
Exemplo n.º 9
0
 def test_name(self):
     person = Person(name='Chris Beaven', country='NZ')
     self.assertEqual(person.country.name, 'New Zealand')
Exemplo n.º 10
0
 def test_custom_field_flag_url(self):
     person = Person(name="Chris Beaven", country="NZ", other_country="US")
     self.assertEqual(person.other_country.flag,
                      "//flags.example.com/us.gif")
Exemplo n.º 11
0
 def test_unicode_flags(self):
     person = Person(name="Matthew Schinckel",
                     country="AU",
                     other_country="DE")
     self.assertEqual(person.country.unicode_flag, "🇦🇺")
     self.assertEqual(person.other_country.unicode_flag, "🇩🇪")
Exemplo n.º 12
0
 def test_name(self):
     person = Person(name="Chris Beaven", country="NZ")
     self.assertEqual(person.country.name, "New Zealand")
Exemplo n.º 13
0
 def test_flag(self):
     person = Person(name="Chris Beaven", country="NZ")
     with self.settings(STATIC_URL="/static-assets/"):
         self.assertEqual(person.country.flag,
                          "/static-assets/flags/nz.gif")
Exemplo n.º 14
0
 def test_text(self):
     person = Person(name="Chris Beaven", country="NZ")
     self.assertEqual(force_str(person.country), "NZ")
Exemplo n.º 15
0
 def test_name(self):
     person = Person(name="Chris Beaven", fantasy_country="NV")
     self.assertEqual(person.fantasy_country.name, "Neverland")
Exemplo n.º 16
0
 def test_validate_alpha3(self):
     person = Person(name="Chris", country="NZL")
     person.full_clean()
Exemplo n.º 17
0
 def test_unicode_flags(self):
     person = Person(
         name='Matthew Schinckel', country='AU', other_country='DE')
     self.assertEqual(person.country.unicode_flag, '🇦🇺')
     self.assertEqual(person.other_country.unicode_flag, '🇩🇪')
Exemplo n.º 18
0
 def test_flag_css(self):
     person = Person(name="Chris Beaven", country="NZ")
     self.assertEqual(person.country.flag_css, "flag-sprite flag-n flag-_z")
Exemplo n.º 19
0
 def test_unicode_flag_blank(self):
     person = Person(name='Matthew Schinckel')
     self.assertEqual(person.country.unicode_flag, '')
Exemplo n.º 20
0
 def test_custom_field_flag_url(self):
     person = Person(name='Chris Beaven', country='NZ', other_country='US')
     self.assertEqual(person.other_country.flag,
                      '//flags.example.com/us.gif')
Exemplo n.º 21
0
 def test_flag_css_blank(self):
     person = Person(name='Chris Beaven')
     self.assertEqual(person.country.flag_css, '')
Exemplo n.º 22
0
 def test_text(self):
     person = Person(name='Chris Beaven', country='NZ')
     self.assertEqual(force_text(person.country), 'NZ')
Exemplo n.º 23
0
 def test_flag(self):
     person = Person(name='Chris Beaven', country='NZ')
     with self.settings(STATIC_URL='/static-assets/'):
         self.assertEqual(person.country.flag,
                          '/static-assets/flags/nz.gif')
Exemplo n.º 24
0
 def test_custom_field_str_attr(self):
     person = Person(name="Quentin Coumes",
                     country="FR",
                     str_attr_country="ES")
     self.assertEqual(str(person.str_attr_country), "Spain")
Exemplo n.º 25
0
    def test_len(self):
        person = Person(name='Chris Beaven', country='NZ')
        self.assertEqual(len(person.country), 2)

        person = Person(name='The Outsider', country=None)
        self.assertEqual(len(person.country), 0)
Exemplo n.º 26
0
 def test_validate_alpha3(self):
     person = Person(name="Chris", country="NZL")
     person.full_clean()
Exemplo n.º 27
0
 def test_validate(self):
     person = Person(name='Chris', country='NZ')
     person.full_clean()
Exemplo n.º 28
0
 def test_flag(self):
     person = Person(name='Chris Beaven', country='NZ')
     self.assertEqual(person.country.flag, '/static-assets/flags/nz.gif')