summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2013-08-03 10:56:42 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2013-08-03 10:56:42 +0200
commit2d7ee18d216a06357e352f5bdbcb3baf5984ce99 (patch)
treedf7d7fd9c09a2ce880fa4ac274a1330b28c60955
parenttest_otultra2: add header. (diff)
downloadglucometerutils-2d7ee18d216a06357e352f5bdbcb3baf5984ce99.tar
glucometerutils-2d7ee18d216a06357e352f5bdbcb3baf5984ce99.tar.gz
glucometerutils-2d7ee18d216a06357e352f5bdbcb3baf5984ce99.tar.bz2
glucometerutils-2d7ee18d216a06357e352f5bdbcb3baf5984ce99.tar.lz
glucometerutils-2d7ee18d216a06357e352f5bdbcb3baf5984ce99.tar.xz
glucometerutils-2d7ee18d216a06357e352f5bdbcb3baf5984ce99.tar.zst
glucometerutils-2d7ee18d216a06357e352f5bdbcb3baf5984ce99.zip
-rw-r--r--test/test_common.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/test_common.py b/test/test_common.py
new file mode 100644
index 0000000..e78b74d
--- /dev/null
+++ b/test/test_common.py
@@ -0,0 +1,53 @@
+"""Tests for the common routines."""
+
+__author__ = 'Diego Elio Pettenò'
+__email__ = 'flameeyes@flameeyes.eu'
+__copyright__ = 'Copyright © 2013, Diego Elio Pettenò'
+__license__ = 'GPL v3 or later'
+
+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 testGlucoseConversion(self):
+ self.assertEqual(
+ 5.56, common.ConvertGlucoseUnit(
+ 100, common.UNIT_MGDL, common.UNIT_MMOLL))
+
+ self.assertEqual(
+ 5.56, common.ConvertGlucoseUnit(
+ 100, common.UNIT_MGDL))
+
+ self.assertEqual(
+ 180, common.ConvertGlucoseUnit(
+ 10, common.UNIT_MMOLL, common.UNIT_MGDL))
+
+ self.assertEqual(
+ 180, common.ConvertGlucoseUnit(
+ 10, common.UNIT_MMOLL))
+
+ self.assertEqual(
+ 100, common.ConvertGlucoseUnit(
+ 100, common.UNIT_MGDL, common.UNIT_MGDL))
+
+ self.assertEqual(
+ 10, common.ConvertGlucoseUnit(
+ 10, common.UNIT_MMOLL, common.UNIT_MMOLL))
+
+ self.assertRaises(
+ exceptions.InvalidGlucoseUnit,
+ common.ConvertGlucoseUnit, common.UNIT_MMOLL, 'foo')
+
+if __name__ == '__main__':
+ unittest.main()