diff options
Diffstat (limited to 'test/test_otultra2.py')
-rw-r--r-- | test/test_otultra2.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/test/test_otultra2.py b/test/test_otultra2.py index 6bea440..6b36602 100644 --- a/test/test_otultra2.py +++ b/test/test_otultra2.py @@ -8,36 +8,36 @@ from unittest import mock from absl.testing import parameterized - +from glucometerutils import exceptions from glucometerutils.drivers import otultra2 from glucometerutils.support import lifescan -from glucometerutils import exceptions class TestOTUltra2(parameterized.TestCase): - def test_checksum(self): - checksum = otultra2._calculate_checksum(b'T') + checksum = otultra2._calculate_checksum(b"T") self.assertEqual(0x0054, checksum) def test_checksum_full(self): - checksum = otultra2._calculate_checksum( - b'T "SAT","08/03/13","22:12:00 "') + checksum = otultra2._calculate_checksum(b'T "SAT","08/03/13","22:12:00 "') self.assertEqual(0x0608, checksum) @parameterized.named_parameters( - ('_missing_checksum', b'INVALID', lifescan.MissingChecksum), - ('_short', b'.\r', exceptions.InvalidResponse), - ('_generic', b'% 2500\r', exceptions.InvalidResponse), - ('_invalid_serial_number', b'@ "12345678O" 0297\r', - lifescan.InvalidSerialNumber), - ('_invalid_checksum', b'% 1337\r', exceptions.InvalidChecksum), - ('_broken_checksum', b'% 13AZ\r', lifescan.MissingChecksum), + ("_missing_checksum", b"INVALID", lifescan.MissingChecksum), + ("_short", b".\r", exceptions.InvalidResponse), + ("_generic", b"% 2500\r", exceptions.InvalidResponse), + ( + "_invalid_serial_number", + b'@ "12345678O" 0297\r', + lifescan.InvalidSerialNumber, + ), + ("_invalid_checksum", b"% 1337\r", exceptions.InvalidChecksum), + ("_broken_checksum", b"% 13AZ\r", lifescan.MissingChecksum), ) def test_invalid_response(self, returned_string, expected_exception): - with mock.patch('serial.Serial') as mock_serial: + with mock.patch("serial.Serial") as mock_serial: mock_serial.return_value.readline.return_value = returned_string - device = otultra2.Device('mockdevice') + device = otultra2.Device("mockdevice") with self.assertRaises(expected_exception): device.get_serial_number() |