aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests/unit/utility
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/tests/unit/utility')
-rw-r--r--wqflask/tests/unit/utility/test_type_checking.py93
1 files changed, 45 insertions, 48 deletions
diff --git a/wqflask/tests/unit/utility/test_type_checking.py b/wqflask/tests/unit/utility/test_type_checking.py
index 1ea11695..48d110c7 100644
--- a/wqflask/tests/unit/utility/test_type_checking.py
+++ b/wqflask/tests/unit/utility/test_type_checking.py
@@ -5,53 +5,50 @@ 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")
-
-
+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 = ["string", 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") \ No newline at end of file