Ejemplo n.º 1
0
 def test_wrong_length(self, n_l):
     """A code that's a prefix of something in the list, but not a valid
     length, is not valid. Or vice-versa."""
     n_l.return_value = ['az-BY']
     self.assertFalse(language_code_is_valid('az-'))
     self.assertFalse(language_code_is_valid('a'))
     self.assertFalse(language_code_is_valid('az-BY2'))
Ejemplo n.º 2
0
 def test_wrong_length(self, n_l):
     """A code that's a prefix of something in the list, but not a valid
     length, is not valid. Or vice-versa."""
     n_l.return_value = ['az-BY']
     self.assertFalse(language_code_is_valid('az-'))
     self.assertFalse(language_code_is_valid('a'))
     self.assertFalse(language_code_is_valid('az-BY2'))
Ejemplo n.º 3
0
    def test_exact_3_letter(self):
        """3-letter code is valid.

        There are a few of these."""
        self.assertTrue(language_code_is_valid('azq'))
Ejemplo n.º 4
0
 def test_prefix(self, n_l):
     """2-letter code that's a prefix of something in the list is valid"""
     n_l.return_value = ['az-BY']
     self.assertTrue(language_code_is_valid('az'))
Ejemplo n.º 5
0
 def test_wrong_length(self):
     """A code that's not a valid length is not valid."""
     self.assertFalse(language_code_is_valid('az-'))
     self.assertFalse(language_code_is_valid('a'))
     self.assertFalse(language_code_is_valid('azqr'))
     self.assertFalse(language_code_is_valid('az-BY2'))
Ejemplo n.º 6
0
 def test_exact_5_letter(self):
     """5-letter code that's in the list is valid"""
     self.assertTrue(language_code_is_valid('az-BY'))
Ejemplo n.º 7
0
 def test_zero(self):
     """0 is a TypeError"""
     with self.assertRaises(TypeError):
         language_code_is_valid(0)
Ejemplo n.º 8
0
 def test_empty_string(self):
     """Empty string is accepted as a language code"""
     self.assertTrue(language_code_is_valid(''))
Ejemplo n.º 9
0
 def test_wrong_length(self):
     """A code that's not a valid length is not valid."""
     self.assertFalse(language_code_is_valid('az-'))
     self.assertFalse(language_code_is_valid('a'))
     self.assertFalse(language_code_is_valid('azqr'))
     self.assertFalse(language_code_is_valid('az-BY2'))
Ejemplo n.º 10
0
 def test_long_version(self, n_l):
     """5-letter code is valid if an entry in the list is a prefix of it"""
     n_l.return_value = ['az']
     self.assertTrue(language_code_is_valid('az-BY'))
Ejemplo n.º 11
0
 def test_prefix(self, n_l):
     """2-letter code that's a prefix of something in the list is valid"""
     n_l.return_value = ['az-BY']
     self.assertTrue(language_code_is_valid('az'))
Ejemplo n.º 12
0
 def test_exact_5_letter(self, n_l):
     """5-letter code that's in the list is valid"""
     n_l.return_value = ['az-BY']
     self.assertTrue(language_code_is_valid('az-BY'))
Ejemplo n.º 13
0
 def test_no_match(self, n_l):
     """Return False if there's no match any way we try."""
     n_l.return_value = ['az']
     self.assertFalse(language_code_is_valid('by'))
Ejemplo n.º 14
0
 def test_case_insensitive(self, n_l):
     """Matching is not case sensitive"""
     n_l.return_value = ['aZ', 'Qw-wE']
     self.assertTrue(language_code_is_valid('az-BY'))
     self.assertTrue(language_code_is_valid('az'))
     self.assertTrue(language_code_is_valid('QW'))
Ejemplo n.º 15
0
 def test_long_version(self, n_l):
     """5-letter code is valid if an entry in the list is a prefix of it"""
     n_l.return_value = ['az']
     self.assertTrue(language_code_is_valid('az-BY'))
Ejemplo n.º 16
0
 def test_exact_5_letter(self):
     """5-letter code that's in the list is valid"""
     self.assertTrue(language_code_is_valid('az-BY'))
Ejemplo n.º 17
0
 def test_case_insensitive(self):
     """Matching is not case sensitive"""
     self.assertTrue(language_code_is_valid('az-BY'))
     self.assertTrue(language_code_is_valid('aZ'))
     self.assertTrue(language_code_is_valid('QW'))
Ejemplo n.º 18
0
 def test_case_insensitive(self, n_l):
     """Matching is not case sensitive"""
     n_l.return_value = ['aZ', 'Qw-wE']
     self.assertTrue(language_code_is_valid('az-BY'))
     self.assertTrue(language_code_is_valid('az'))
     self.assertTrue(language_code_is_valid('QW'))
Ejemplo n.º 19
0
 def test_wrong_format(self):
     """A code that's not a valid format is not valid."""
     self.assertFalse(language_code_is_valid('a2'))
     self.assertFalse(language_code_is_valid('asdfj'))
     self.assertFalse(language_code_is_valid('az_BY'))
Ejemplo n.º 20
0
 def test_no_match(self, n_l):
     """Return False if there's no match any way we try."""
     n_l.return_value = ['az']
     self.assertFalse(language_code_is_valid('by'))
Ejemplo n.º 21
0
 def test_none(self):
     """None is a TypeError"""
     with self.assertRaises(TypeError):
         language_code_is_valid(None)
Ejemplo n.º 22
0
 def test_empty_string(self):
     """Empty string is accepted as a language code"""
     self.assertTrue(language_code_is_valid(''))
Ejemplo n.º 23
0
    def test_exact_3_letter(self):
        """3-letter code is valid.

        There are a few of these."""
        self.assertTrue(language_code_is_valid('azq'))
Ejemplo n.º 24
0
 def test_none(self):
     """None is a TypeError"""
     with self.assertRaises(TypeError):
         language_code_is_valid(None)
Ejemplo n.º 25
0
 def test_case_insensitive(self):
     """Matching is not case sensitive"""
     self.assertTrue(language_code_is_valid('az-BY'))
     self.assertTrue(language_code_is_valid('aZ'))
     self.assertTrue(language_code_is_valid('QW'))
Ejemplo n.º 26
0
 def test_zero(self):
     """0 is a TypeError"""
     with self.assertRaises(TypeError):
         language_code_is_valid(0)
Ejemplo n.º 27
0
 def test_wrong_format(self):
     """A code that's not a valid format is not valid."""
     self.assertFalse(language_code_is_valid('a2'))
     self.assertFalse(language_code_is_valid('asdfj'))
     self.assertFalse(language_code_is_valid('az_BY'))
Ejemplo n.º 28
0
 def test_exact_5_letter(self, n_l):
     """5-letter code that's in the list is valid"""
     n_l.return_value = ['az-BY']
     self.assertTrue(language_code_is_valid('az-BY'))