aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2020-10-27 14:33:06 +0300
committerGitHub2020-10-27 14:33:06 +0300
commitcc75b6ad2220d9875ce7b21433eb3fb175b5216f (patch)
tree4dff873a274c3a278a175b53865e8f828645bf35
parent37c391bc62e9080effcf83c6ff0056ab8841b7fb (diff)
parentabf3758d86c1ee37e458d79e62be69e4c23e515c (diff)
downloadgenenetwork2-cc75b6ad2220d9875ce7b21433eb3fb175b5216f.tar.gz
Merge pull request #465 from Alexanderlacuna/test-branch
add test for trait_data
-rw-r--r--wqflask/tests/wqflask/show_trait/__init__.py0
-rw-r--r--wqflask/tests/wqflask/show_trait/test_export_trait_data.py94
2 files changed, 94 insertions, 0 deletions
diff --git a/wqflask/tests/wqflask/show_trait/__init__.py b/wqflask/tests/wqflask/show_trait/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/tests/wqflask/show_trait/__init__.py
diff --git a/wqflask/tests/wqflask/show_trait/test_export_trait_data.py b/wqflask/tests/wqflask/show_trait/test_export_trait_data.py
new file mode 100644
index 00000000..98d599b1
--- /dev/null
+++ b/wqflask/tests/wqflask/show_trait/test_export_trait_data.py
@@ -0,0 +1,94 @@
+import unittest
+from wqflask.show_trait.export_trait_data import dict_to_sorted_list
+from wqflask.show_trait.export_trait_data import cmp_samples
+
+
+class TestExportTraits(unittest.TestCase):
+ """Test methods related to converting dict to sortedlist"""
+
+ def test_dict_to_sortedlist(self):
+ """test for conversion of dict to sorted list"""
+ sample1 = {
+ "other": "exp1",
+ "name": "exp2"
+ }
+ sample2 = {
+ "se": 1,
+ "num_cases": 4,
+ "value": 6,
+ "name": 3
+
+ }
+ rever = {
+ "name": 3,
+ "value": 6,
+ "num_cases": 4,
+ "se": 1
+ }
+ oneItem = {
+ "item1": "one"
+ }
+
+ self.assertEqual(["exp2", "exp1"], dict_to_sorted_list(sample1))
+ self.assertEqual([3, 6, 1, 4], dict_to_sorted_list(sample2))
+ self.assertEqual([3, 6, 1, 4], dict_to_sorted_list(rever))
+ self.assertEqual(["one"], dict_to_sorted_list(oneItem))
+ """test that the func returns the values not the keys"""
+ self.assertFalse(["other", "name"] == dict_to_sorted_list(sample1))
+
+ def test_cmp_samples(self):
+ """test for comparing samples function"""
+ sampleA = [
+ [
+ ("value", "other"),
+ ("name", "test_name")
+ ]
+ ]
+ sampleB = [
+ [
+ ("value", "other"),
+ ("unknown", "test_name")
+ ]
+ ]
+ sampleC = [
+ [("other", "value"),
+ ("name", "value")
+ ],
+ [
+ ("name", "value"),
+ ("value", "name")
+ ],
+ [
+ ("other", "value"),
+ ("name", "value"
+ )],
+ [
+ ("name", "name1"),
+ ("se", "valuex")
+ ],
+ [(
+ "value", "name1"),
+ ("se", "valuex")
+ ],
+ [(
+ "other", "name1"),
+ ("se", "valuex"
+ )
+ ],
+ [(
+ "name", "name_val"),
+ ("num_cases", "num_val")
+ ],
+ [(
+ "other_a", "val_a"),
+ ("other_b", "val"
+ )
+ ]
+ ]
+ results = [cmp_samples(val[0], val[1]) for val in sampleA]
+ resultB = [cmp_samples(val[0], val[1]) for val in sampleB]
+ resultC = [cmp_samples(val[0], val[1]) for val in sampleC]
+
+ self.assertEqual(1, *results)
+ self.assertEqual(-1, *resultB)
+ self.assertEqual([1, -1, 1, -1, -1, 1, -1, -1], resultC)