From b0f52759910837f35bfceedc2cbc23bcd0d9f18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Thu, 15 Nov 2018 23:31:22 +0000 Subject: otultraeasy: factor out the packet creation, and add tests. This would have caught the bug fixed with the previous commit, which is a strict improvement. --- test/test_otultraeasy.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/test_otultraeasy.py (limited to 'test') diff --git a/test/test_otultraeasy.py b/test/test_otultraeasy.py new file mode 100644 index 0000000..6d802db --- /dev/null +++ b/test/test_otultraeasy.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +"""Tests for the LifeScan OneTouch Ultra Easy driver.""" + +__author__ = 'Diego Elio Pettenò' +__email__ = 'flameeyes@flameeyes.eu' +__copyright__ = 'Copyright © 2018, Diego Elio Pettenò' +__license__ = 'MIT' + +# pylint: disable=protected-access,missing-docstring + +from absl.testing import absltest + +from glucometerutils.drivers import otultraeasy + + +class ConstructTest(absltest.TestCase): + + def test_make_packet_ack(self): + self.assertEqual( + b'\x02\x06\x08\x03\xc2\x62', + otultraeasy._make_packet(b'', False, False, False, True)) + + def test_make_packet_version_request(self): + self.assertEqual( + 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() -- cgit v1.2.3