aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests
diff options
context:
space:
mode:
authorAlexanderkabui2020-12-14 16:11:07 +0300
committerBonfaceKilz2021-01-06 01:29:02 +0300
commitdb3170eb2fe66d8fd337803a730c18367df1b150 (patch)
tree5c8c6f8a00a6b4300183285f6015a970d98c8cef /wqflask/tests
parentf2e4e893f5639f216f8cc6fc57984aaebffd82ef (diff)
downloadgenenetwork2-db3170eb2fe66d8fd337803a730c18367df1b150.tar.gz
add tests for type checking
Diffstat (limited to 'wqflask/tests')
-rw-r--r--wqflask/tests/unit/utility/test_type_checking.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/wqflask/tests/unit/utility/test_type_checking.py b/wqflask/tests/unit/utility/test_type_checking.py
new file mode 100644
index 00000000..1ea11695
--- /dev/null
+++ b/wqflask/tests/unit/utility/test_type_checking.py
@@ -0,0 +1,57 @@
+import unittest
+from utility.type_checking import is_float
+from utility.type_checking import is_int
+from utility.type_checking import is_str
+from utility.type_checking import get_float
+from utility.type_checking import get_int
+from utility.type_checking import get_string
+class TestTypeChecking(unittest.TestCase):
+ def test_is_float(self):
+ floats=[2,1.2,'3.1']
+ not_floats=["String",None,[],()]
+ for flt in floats:
+ results=is_float(flt)
+ self.assertTrue(results)
+ for nflt in not_floats:
+ results=is_float(nflt)
+ self.assertFalse(results)
+
+ def test_is_int(self):
+ int_values=[1,1.1]
+ not_int_values=["1sdf",None,[],"1.1"]
+ for int_val in int_values:
+ results=is_int(int_val)
+ self.assertTrue(results)
+ for not_int in not_int_values:
+ results=is_int(not_int)
+ self.assertFalse(results)
+
+ def test_is_str(self):
+ string_values=[1,False,[],{},"string_value"]
+ falsey_values=[None]
+ for string_val in string_values:
+ results=is_str(string_val)
+ self.assertTrue(results)
+ for non_string in falsey_values:
+ results=is_str(non_string)
+ self.assertFalse(results)
+
+
+ def test_get_float(self):
+ vars_object={"min_value":"12"}
+ results=get_float(vars_object,"min_value")
+ self.assertEqual(results,12.0)
+
+ def test_get_int(self):
+ vars_object={"lx_value":"1"}
+ results=get_int(vars_object,"lx_value")
+ self.assertEqual(results,1)
+
+ def test_get_string(self):
+ string_object={"mx_value":1}
+ results=get_string(string_object,"mx_value")
+ self.assertEqual(results,"1")
+
+
+
+