summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2013-09-29 21:24:18 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2013-09-29 21:24:18 +0200
commit49e253fd606d47508d1b449325718f855c263d0a (patch)
tree4cabbe693617e2158e9691a328110276e4b8e7fc /test
parenttest_otultra2: factor out setting of returned serial string. (diff)
downloadglucometerutils-49e253fd606d47508d1b449325718f855c263d0a.tar
glucometerutils-49e253fd606d47508d1b449325718f855c263d0a.tar.gz
glucometerutils-49e253fd606d47508d1b449325718f855c263d0a.tar.bz2
glucometerutils-49e253fd606d47508d1b449325718f855c263d0a.tar.lz
glucometerutils-49e253fd606d47508d1b449325718f855c263d0a.tar.xz
glucometerutils-49e253fd606d47508d1b449325718f855c263d0a.tar.zst
glucometerutils-49e253fd606d47508d1b449325718f855c263d0a.zip
Diffstat (limited to 'test')
-rw-r--r--test/test_common.py51
-rw-r--r--test/test_lifescan.py14
-rw-r--r--test/test_otultra2.py63
3 files changed, 60 insertions, 68 deletions
diff --git a/test/test_common.py b/test/test_common.py
index 1f6c8da..07b65d9 100644
--- a/test/test_common.py
+++ b/test/test_common.py
@@ -10,45 +10,40 @@ import os
import sys
import unittest
-import mock
-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from glucometerutils import common
from glucometerutils import exceptions
class TestCommon(unittest.TestCase):
- def setUp(self):
- pass
-
- def test_glucose_conversion(self):
- self.assertEqual(
- 5.56, common.convert_glucose_unit(
- 100, common.UNIT_MGDL, common.UNIT_MMOLL))
+ def test_glucose_conversion(self):
+ self.assertEqual(
+ 5.56, common.convert_glucose_unit(
+ 100, common.UNIT_MGDL, common.UNIT_MMOLL))
- self.assertEqual(
- 5.56, common.convert_glucose_unit(
- 100, common.UNIT_MGDL))
+ self.assertEqual(
+ 5.56, common.convert_glucose_unit(
+ 100, common.UNIT_MGDL))
- self.assertEqual(
- 180, common.convert_glucose_unit(
- 10, common.UNIT_MMOLL, common.UNIT_MGDL))
+ self.assertEqual(
+ 180, common.convert_glucose_unit(
+ 10, common.UNIT_MMOLL, common.UNIT_MGDL))
- self.assertEqual(
- 180, common.convert_glucose_unit(
- 10, common.UNIT_MMOLL))
+ self.assertEqual(
+ 180, common.convert_glucose_unit(
+ 10, common.UNIT_MMOLL))
- self.assertEqual(
- 100, common.convert_glucose_unit(
- 100, common.UNIT_MGDL, common.UNIT_MGDL))
+ self.assertEqual(
+ 100, common.convert_glucose_unit(
+ 100, common.UNIT_MGDL, common.UNIT_MGDL))
- self.assertEqual(
- 10, common.convert_glucose_unit(
- 10, common.UNIT_MMOLL, common.UNIT_MMOLL))
+ self.assertEqual(
+ 10, common.convert_glucose_unit(
+ 10, common.UNIT_MMOLL, common.UNIT_MMOLL))
- self.assertRaises(
- exceptions.InvalidGlucoseUnit,
- common.convert_glucose_unit, common.UNIT_MMOLL, 'foo')
+ self.assertRaises(
+ exceptions.InvalidGlucoseUnit,
+ common.convert_glucose_unit, common.UNIT_MMOLL, 'foo')
if __name__ == '__main__':
- unittest.main()
+ unittest.main()
diff --git a/test/test_lifescan.py b/test/test_lifescan.py
index d18152d..7252bec 100644
--- a/test/test_lifescan.py
+++ b/test/test_lifescan.py
@@ -12,19 +12,17 @@ import unittest
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from glucometerutils import common
from glucometerutils.drivers import lifescan_common
-from glucometerutils import exceptions
class TestOTUltra2(unittest.TestCase):
- def testChecksum(self):
- checksum = lifescan_common.calculate_checksum(bytes('T', 'ascii'))
- self.assertEqual(0x0054, checksum)
+ def test_checksum(self):
+ checksum = lifescan_common.calculate_checksum(bytes('T', 'ascii'))
+ self.assertEqual(0x0054, checksum)
- checksum = lifescan_common.calculate_checksum(
- bytes('T "SAT","08/03/13","22:12:00 "', 'ascii'))
- self.assertEqual(0x0608, checksum)
+ checksum = lifescan_common.calculate_checksum(
+ bytes('T "SAT","08/03/13","22:12:00 "', 'ascii'))
+ self.assertEqual(0x0608, checksum)
if __name__ == '__main__':
unittest.main()
diff --git a/test/test_otultra2.py b/test/test_otultra2.py
index 5474c1f..5007ca7 100644
--- a/test/test_otultra2.py
+++ b/test/test_otultra2.py
@@ -14,58 +14,57 @@ import mock
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from glucometerutils import common
from glucometerutils.drivers import lifescan_common
from glucometerutils.drivers import otultra2
from glucometerutils import exceptions
class TestOTUltra2(unittest.TestCase):
- def setUp(self):
- self.addCleanup(mock.patch.stopall)
+ def setUp(self):
+ self.addCleanup(mock.patch.stopall)
- mock_serial = mock.patch('serial.Serial').start()
- self.mock_readline = mock_serial.return_value.readline
+ mock_serial = mock.patch('serial.Serial').start()
+ self.mock_readline = mock_serial.return_value.readline
- self.device = otultra2.Device('mockdevice')
+ self.device = otultra2.Device('mockdevice')
- def _set_return_string(self, string):
- self.mock_readline.return_value = bytes(string, 'ascii')
+ def _set_return_string(self, string):
+ self.mock_readline.return_value = bytes(string, 'ascii')
- def testMissingChecksum(self):
- self._set_return_string('INVALID')
+ def test_missing_checksum(self):
+ self._set_return_string('INVALID')
- self.assertRaises(lifescan_common.MissingChecksum,
- self.device.get_serial_number)
+ self.assertRaises(lifescan_common.MissingChecksum,
+ self.device.get_serial_number)
- def testShortResponse(self):
- self._set_return_string('.\r')
+ def test_short_response(self):
+ self._set_return_string('.\r')
- self.assertRaises(exceptions.InvalidResponse,
- self.device.get_serial_number)
+ self.assertRaises(exceptions.InvalidResponse,
+ self.device.get_serial_number)
- def testInvalidResponse(self):
- self._set_return_string('% 2500\r')
+ def test_invalid_response(self):
+ self._set_return_string('% 2500\r')
- self.assertRaises(exceptions.InvalidResponse,
- self.device.get_serial_number)
+ self.assertRaises(exceptions.InvalidResponse,
+ self.device.get_serial_number)
- def testInvalidSerialNumber(self):
- self._set_return_string('@ "12345678O" 0297\r')
+ def test_invalid_serial_number(self):
+ self._set_return_string('@ "12345678O" 0297\r')
- self.assertRaises(lifescan_common.InvalidSerialNumber,
- self.device.get_serial_number)
+ self.assertRaises(lifescan_common.InvalidSerialNumber,
+ self.device.get_serial_number)
- def testInvalidChecksum(self):
- self._set_return_string('% 1337\r')
+ def test_invalid_checksum(self):
+ self._set_return_string('% 1337\r')
- self.assertRaises(lifescan_common.InvalidChecksum,
- self.device.get_serial_number)
+ self.assertRaises(lifescan_common.InvalidChecksum,
+ self.device.get_serial_number)
- def testBrokenChecksum(self):
- self._set_return_string('% 13AZ\r')
+ def test_broken_checksum(self):
+ self._set_return_string('% 13AZ\r')
- self.assertRaises(lifescan_common.MissingChecksum,
- self.device.get_serial_number)
+ self.assertRaises(lifescan_common.MissingChecksum,
+ self.device.get_serial_number)
if __name__ == '__main__':
unittest.main()