From f5143327b243fc616f37252d76bd31f2690b088d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 16 Mar 2020 18:51:27 +0000 Subject: Move tests to be organized within the source directory. This should simplify maintaining the tests in the long run, and allows mypy to more thoroughly check for types. --- test/test_otultra2.py | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 test/test_otultra2.py (limited to 'test/test_otultra2.py') diff --git a/test/test_otultra2.py b/test/test_otultra2.py deleted file mode 100644 index 6b36602..0000000 --- a/test/test_otultra2.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# -# SPDX-License-Identifier: MIT -"""Tests for the LifeScan OneTouch Ultra 2 driver.""" - -# pylint: disable=protected-access,missing-docstring - -from unittest import mock - -from absl.testing import parameterized -from glucometerutils import exceptions -from glucometerutils.drivers import otultra2 -from glucometerutils.support import lifescan - - -class TestOTUltra2(parameterized.TestCase): - def test_checksum(self): - 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 "') - 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), - ) - def test_invalid_response(self, returned_string, expected_exception): - with mock.patch("serial.Serial") as mock_serial: - mock_serial.return_value.readline.return_value = returned_string - - device = otultra2.Device("mockdevice") - with self.assertRaises(expected_exception): - device.get_serial_number() -- cgit v1.2.3