|
6 | 6 | class EncodingUtilsTest(unittest.TestCase): |
7 | 7 |
|
8 | 8 | def test_hex_encode(self): |
9 | | - enc_one = to_test.encode_bytes(bytes(1), to_test.Encoding.HEX) |
10 | | - enc_string = to_test.encode_bytes(b"some data", to_test.Encoding.HEX) |
11 | | - enc_empty = to_test.encode_bytes(b"", to_test.Encoding.HEX) |
| 9 | + enc_one = to_test.encode_bytes(bytes(1), to_test.ClientEncoding.HEX) |
| 10 | + enc_string = to_test.encode_bytes(b"some data", to_test.ClientEncoding.HEX) |
| 11 | + enc_empty = to_test.encode_bytes(b"", to_test.ClientEncoding.HEX) |
12 | 12 |
|
13 | 13 | self.assertEqual("00", enc_one, "Encoded bytes not matching") |
14 | 14 | self.assertEqual("736f6d652064617461", enc_string, "Encoded bytes not matching") |
15 | 15 | self.assertEqual("", enc_empty, "Encoded bytes not matching") |
16 | 16 |
|
17 | 17 | def test_hex_decode(self): |
18 | | - dec_one = to_test.decode_value("00", to_test.Encoding.HEX) |
19 | | - dec_string = to_test.decode_value("736f6d652064617461", to_test.Encoding.HEX) |
20 | | - dec_empty = to_test.decode_value("", to_test.Encoding.HEX) |
| 18 | + dec_one = to_test.decode_value("00", to_test.ClientEncoding.HEX) |
| 19 | + dec_string = to_test.decode_value("736f6d652064617461", to_test.ClientEncoding.HEX) |
| 20 | + dec_empty = to_test.decode_value("", to_test.ClientEncoding.HEX) |
21 | 21 |
|
22 | 22 | self.assertEqual(bytes(1), dec_one, "Decoded value not matching") |
23 | 23 | self.assertEqual(b"some data", dec_string, "Decoded value not matching") |
24 | 24 | self.assertEqual(b"", dec_empty, "Decoded value not matching") |
25 | 25 |
|
26 | 26 | def test_hex_decode_not_valid_hex(self): |
27 | | - self.assertRaises(ValueError, to_test.decode_value, "736f6d65p064617461", to_test.Encoding.HEX) |
| 27 | + self.assertRaises(ValueError, to_test.decode_value, "736f6d65p064617461", to_test.ClientEncoding.HEX) |
28 | 28 |
|
29 | 29 | def test_base64_encode(self): |
30 | | - enc_one = to_test.encode_bytes(bytes(1), to_test.Encoding.BASE64) |
31 | | - enc_string = to_test.encode_bytes(b"some data", to_test.Encoding.BASE64) |
32 | | - enc_empty = to_test.encode_bytes(b"", to_test.Encoding.BASE64) |
| 30 | + enc_one = to_test.encode_bytes(bytes(1), to_test.ClientEncoding.BASE64) |
| 31 | + enc_string = to_test.encode_bytes(b"some data", to_test.ClientEncoding.BASE64) |
| 32 | + enc_empty = to_test.encode_bytes(b"", to_test.ClientEncoding.BASE64) |
33 | 33 |
|
34 | 34 | self.assertEqual("AA==", enc_one, "Encoded bytes not matching") |
35 | 35 | self.assertEqual("c29tZSBkYXRh", enc_string, "Encoded bytes not matching") |
36 | 36 | self.assertEqual("", enc_empty, "Encoded bytes not matching") |
37 | 37 |
|
38 | 38 | def test_base64_decode(self): |
39 | | - dec_one = to_test.decode_value("AA==", to_test.Encoding.BASE64) |
40 | | - dec_string = to_test.decode_value("c29tZSBkYXRh", to_test.Encoding.BASE64) |
41 | | - dec_empty = to_test.decode_value("", to_test.Encoding.BASE64) |
| 39 | + dec_one = to_test.decode_value("AA==", to_test.ClientEncoding.BASE64) |
| 40 | + dec_string = to_test.decode_value("c29tZSBkYXRh", to_test.ClientEncoding.BASE64) |
| 41 | + dec_empty = to_test.decode_value("", to_test.ClientEncoding.BASE64) |
42 | 42 |
|
43 | 43 | self.assertEqual(bytes(1), dec_one, "Decoded value not matching") |
44 | 44 | self.assertEqual(b"some data", dec_string, "Decoded value not matching") |
45 | 45 | self.assertEqual(b"", dec_empty, "Decoded value not matching") |
46 | 46 |
|
47 | 47 | def test_base64_decode_not_valid_base64(self): |
48 | | - self.assertRaises(ValueError, to_test.decode_value, "c29tZS?kYXRh", to_test.Encoding.BASE64) |
| 48 | + self.assertRaises(ValueError, to_test.decode_value, "c29tZS?kYXRh", to_test.ClientEncoding.BASE64) |
49 | 49 |
|
50 | 50 | def test_encode_no_value(self): |
51 | | - self.assertRaises(ValueError, to_test.encode_bytes, None, to_test.Encoding.HEX) |
52 | | - self.assertRaises(ValueError, to_test.encode_bytes, None, to_test.Encoding.BASE64) |
| 51 | + self.assertRaises(ValueError, to_test.encode_bytes, None, to_test.ClientEncoding.HEX) |
| 52 | + self.assertRaises(ValueError, to_test.encode_bytes, None, to_test.ClientEncoding.BASE64) |
53 | 53 |
|
54 | 54 | def test_encode_not_a_byte_sequence(self): |
55 | | - self.assertRaises(ValueError, to_test.encode_bytes, "not a byte sequence", to_test.Encoding.HEX) |
56 | | - self.assertRaises(ValueError, to_test.encode_bytes, "not a byte sequence", to_test.Encoding.BASE64) |
| 55 | + self.assertRaises(ValueError, to_test.encode_bytes, "not a byte sequence", to_test.ClientEncoding.HEX) |
| 56 | + self.assertRaises(ValueError, to_test.encode_bytes, "not a byte sequence", to_test.ClientEncoding.BASE64) |
57 | 57 |
|
58 | 58 | def test_encode_invalid_encoding(self): |
59 | 59 | self.assertRaises(EncodingError, to_test.encode_bytes, b"whatever", "ABC") |
60 | 60 |
|
61 | 61 | def test_decode_no_value(self): |
62 | | - self.assertRaises(ValueError, to_test.decode_value, None, to_test.Encoding.HEX) |
63 | | - self.assertRaises(ValueError, to_test.decode_value, None, to_test.Encoding.BASE64) |
| 62 | + self.assertRaises(ValueError, to_test.decode_value, None, to_test.ClientEncoding.HEX) |
| 63 | + self.assertRaises(ValueError, to_test.decode_value, None, to_test.ClientEncoding.BASE64) |
64 | 64 |
|
65 | 65 | def test_decode_not_a_string(self): |
66 | | - self.assertRaises(ValueError, to_test.decode_value, b"736f6d652064617461", to_test.Encoding.HEX) |
67 | | - self.assertRaises(ValueError, to_test.decode_value, b"736f6d652064617461", to_test.Encoding.BASE64) |
| 66 | + self.assertRaises(ValueError, to_test.decode_value, b"736f6d652064617461", to_test.ClientEncoding.HEX) |
| 67 | + self.assertRaises(ValueError, to_test.decode_value, b"736f6d652064617461", to_test.ClientEncoding.BASE64) |
68 | 68 |
|
69 | 69 | def test_decode_invalid_encoding(self): |
70 | 70 | self.assertRaises(EncodingError, to_test.decode_value, "whatever", "ABC") |
0 commit comments