From 60eef1be7ebfce29b79f2eb88e076c63cd0290e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 1 Jan 2018 14:48:16 +0000 Subject: test_lifescan: rename from test_otultraeasy, and cleanup. This test was actually only testing the CRC CCITT implementation now that otultraeasy uses construct. --- test/test_lifescan.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/test_lifescan.py (limited to 'test/test_lifescan.py') diff --git a/test/test_lifescan.py b/test/test_lifescan.py new file mode 100644 index 0000000..5781829 --- /dev/null +++ b/test/test_lifescan.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +"""Tests for the LifeScan OneTouch Ultra Mini driver.""" + +__author__ = 'Diego Elio Pettenò' +__email__ = 'flameeyes@flameeyes.eu' +__copyright__ = 'Copyright © 2013-2017, Diego Elio Pettenò' +__license__ = 'MIT' + +import array +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from glucometerutils.support import lifescan + +class TestChecksum(unittest.TestCase): + def test_crc(self): + self.assertEqual( + 0x41cd, + lifescan.crc_ccitt(b'\x02\x06\x06\x03')) + + def test_crc_array(self): + cmd_array = array.array('B', b'\x02\x06\x08\x03') + self.assertEqual( + 0x62C2, + lifescan.crc_ccitt(cmd_array)) + + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3