Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #7
0
 def test_zero(self):
     """0 is a TypeError"""
     with self.assertRaises(TypeError):
         language_code_is_valid(0)
Example #8
0
 def test_empty_string(self):
     """Empty string is accepted as a language code"""
     self.assertTrue(language_code_is_valid(''))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #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'))
Example #21
0
 def test_none(self):
     """None is a TypeError"""
     with self.assertRaises(TypeError):
         language_code_is_valid(None)
Example #22
0
 def test_empty_string(self):
     """Empty string is accepted as a language code"""
     self.assertTrue(language_code_is_valid(''))
Example #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'))
Example #24
0
 def test_none(self):
     """None is a TypeError"""
     with self.assertRaises(TypeError):
         language_code_is_valid(None)
Example #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'))
Example #26
0
 def test_zero(self):
     """0 is a TypeError"""
     with self.assertRaises(TypeError):
         language_code_is_valid(0)
Example #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'))
Example #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'))