diff options
author | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2018-11-16 00:52:39 +0100 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2018-11-16 00:52:39 +0100 |
commit | d7265e672035c29b486929caf49d5a9246421d8a (patch) | |
tree | 9a6102ce1ee7389dcdd2ccb2a16aff819c8b4ea4 /test | |
parent | otultraeasy: factor out the packet creation, and add tests. (diff) | |
download | glucometerutils-d7265e672035c29b486929caf49d5a9246421d8a.tar glucometerutils-d7265e672035c29b486929caf49d5a9246421d8a.tar.gz glucometerutils-d7265e672035c29b486929caf49d5a9246421d8a.tar.bz2 glucometerutils-d7265e672035c29b486929caf49d5a9246421d8a.tar.lz glucometerutils-d7265e672035c29b486929caf49d5a9246421d8a.tar.xz glucometerutils-d7265e672035c29b486929caf49d5a9246421d8a.tar.zst glucometerutils-d7265e672035c29b486929caf49d5a9246421d8a.zip |
Diffstat (limited to '')
-rw-r--r-- | test/__init__.py | 12 | ||||
-rw-r--r-- | test/test_common.py | 11 | ||||
-rw-r--r-- | test/test_construct_extras.py | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | test/test_lifescan.py | 14 | ||||
-rw-r--r-- | test/test_otultra2.py | 13 | ||||
-rw-r--r-- | test/test_otultraeasy.py | 3 |
6 files changed, 26 insertions, 41 deletions
diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..8865d55 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +"""Add the top-level module to the PYTHONPATH.""" + +__author__ = 'Diego Elio Pettenò' +__email__ = 'flameeyes@flameeyes.eu' +__copyright__ = 'Copyright © 2018, Diego Elio Pettenò' +__license__ = 'MIT' + +import os +import sys + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) diff --git a/test/test_common.py b/test/test_common.py index 4b062ac..b31d55c 100644 --- a/test/test_common.py +++ b/test/test_common.py @@ -6,15 +6,12 @@ __email__ = 'flameeyes@flameeyes.eu' __copyright__ = 'Copyright © 2013-2018, Diego Elio Pettenò' __license__ = 'MIT' +# pylint: disable=protected-access,missing-docstring + import datetime -import os -import sys -import unittest from absl.testing import parameterized -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - from glucometerutils import common @@ -123,7 +120,3 @@ class TestMeterInfo(parameterized.TestCase): def test_meter_info(self, kwargs_dict, expected_fragment): info = common.MeterInfo(self.id(), **kwargs_dict) self.assertIn(expected_fragment, str(info)) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_construct_extras.py b/test/test_construct_extras.py index b0cd1c3..65bc047 100644 --- a/test/test_construct_extras.py +++ b/test/test_construct_extras.py @@ -6,15 +6,13 @@ __email__ = 'flameeyes@flameeyes.eu' __copyright__ = 'Copyright © 2018, Diego Elio Pettenò' __license__ = 'MIT' +# pylint: disable=protected-access,missing-docstring + import datetime -import os -import sys -import unittest +from absl.testing import absltest import construct -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - from glucometerutils.support import construct_extras @@ -24,7 +22,7 @@ _TEST_DATE3 = datetime.datetime(1970, 1, 1, 0, 0) _NEW_EPOCH = 31536000 # datetime.datetime(1971, 1, 1, 0, 0) -class TestTimestamp(unittest.TestCase): +class TestTimestamp(absltest.TestCase): def test_build_unix_epoch(self): self.assertEqual( @@ -69,7 +67,3 @@ class TestTimestamp(unittest.TestCase): def test_invalid_value(self): with self.assertRaises(AssertionError): construct_extras.Timestamp(construct.Int32ul).build('foo') - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_lifescan.py b/test/test_lifescan.py index 5781829..45f2c1c 100644..100755 --- a/test/test_lifescan.py +++ b/test/test_lifescan.py @@ -6,16 +6,16 @@ __email__ = 'flameeyes@flameeyes.eu' __copyright__ = 'Copyright © 2013-2017, Diego Elio Pettenò' __license__ = 'MIT' +# pylint: disable=protected-access,missing-docstring + import array -import os -import sys -import unittest -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from absl.testing import absltest from glucometerutils.support import lifescan -class TestChecksum(unittest.TestCase): + +class TestChecksum(absltest.TestCase): def test_crc(self): self.assertEqual( 0x41cd, @@ -26,7 +26,3 @@ class TestChecksum(unittest.TestCase): self.assertEqual( 0x62C2, lifescan.crc_ccitt(cmd_array)) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_otultra2.py b/test/test_otultra2.py index b421c79..608e93b 100644 --- a/test/test_otultra2.py +++ b/test/test_otultra2.py @@ -6,28 +6,24 @@ __email__ = 'flameeyes@flameeyes.eu' __copyright__ = 'Copyright © 2013-2018, Diego Elio Pettenò' __license__ = 'MIT' -import os -import sys -import unittest +# pylint: disable=protected-access,missing-docstring + from unittest import mock from absl.testing import parameterized -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - from glucometerutils.drivers import otultra2 from glucometerutils.support import lifescan from glucometerutils import exceptions + class TestOTUltra2(parameterized.TestCase): def test_checksum(self): - # pylint: disable=protected-access checksum = otultra2._calculate_checksum(b'T') self.assertEqual(0x0054, checksum) def test_checksum_full(self): - # pylint: disable=protected-access checksum = otultra2._calculate_checksum( b'T "SAT","08/03/13","22:12:00 "') self.assertEqual(0x0608, checksum) @@ -48,6 +44,3 @@ class TestOTUltra2(parameterized.TestCase): device = otultra2.Device('mockdevice') with self.assertRaises(expected_exception): device.get_serial_number() - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_otultraeasy.py b/test/test_otultraeasy.py index 6d802db..2e1b093 100644 --- a/test/test_otultraeasy.py +++ b/test/test_otultraeasy.py @@ -25,6 +25,3 @@ class ConstructTest(absltest.TestCase): b'\x02\x09\x03\x05\x0d\x02\x03\x08\x9f', otultraeasy._make_packet( b'\x05\x0d\x02', True, True, False, False)) - -if __name__ == '__main__': - absltest.main() |