diff options
author | zsloan | 2021-01-11 13:22:48 -0600 |
---|---|---|
committer | GitHub | 2021-01-11 13:22:48 -0600 |
commit | 212a0c4bd212fd4100a2738a17ef839a67ae7959 (patch) | |
tree | f7974d4a914891458f8c3b8eeafa6c2c803d42bc /wqflask/tests/unit/utility | |
parent | e7324bf55b7dcfd46f7a2ab52765977fb189c26b (diff) | |
parent | 0d96ca92fb45d8bb2a6990f7d830fa9fb8315b0a (diff) | |
download | genenetwork2-212a0c4bd212fd4100a2738a17ef839a67ae7959.tar.gz |
Merge branch 'testing' into feature/add_location_type_correlation_option
Diffstat (limited to 'wqflask/tests/unit/utility')
-rw-r--r-- | wqflask/tests/unit/utility/test_type_checking.py | 54 |
1 files changed, 54 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..48d110c7 --- /dev/null +++ b/wqflask/tests/unit/utility/test_type_checking.py @@ -0,0 +1,54 @@ +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 = ["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 |