Commits

Andrew Dalke committed 0bbf300

Add test cases for the new threshold option

Comments (0)

Files changed (1)

tests/test_commandline.py

         stdout, stderr = run("../sample_files/ace.sdf --output-format fragment-sdf")
 
 
+class TestThreshold(unittest.TestCase):
+    def test_default_threshold_topology(self):
+        # Match everything
+        confirm("threshold.smi --compare topology --threshold 1.0", 5, 4, "[*]~[*]~[*]~[*]~[*]")
+    def test_30_percent_topology(self):
+        # Only need to match three.
+        confirm("threshold.smi --compare topology --threshold 0.3", 7, 6, "[*]~[*]~[*]~[*]~[*]~[*]~[*]")
+    def test_0_percent_topology(self):
+        # Only need to match two.
+        confirm("threshold.smi --compare topology --threshold 0", 7, 7)
+        
+    def test_60_percent(self):
+        # Need to match 6
+        confirm("threshold.smi --threshold 0.6", 5, 4, "[#6]-[#6]-[#6]-[#6]-[#6]")
+
+    def test_60_percent_ring_only(self):
+        # Need to match 6
+        confirm("threshold.smi --threshold 0.6 --ring-matches-ring-only", 2, 1, "[#6]-!@[#8]")
+
+    def test_that_size_rejection_does_not_affect_the_threshold_calculation(self):
+        confirm("threshold.smi --min-num-atoms 7 --threshold 0.5", None, None)
+        confirm("threshold.smi --min-num-atoms 7 --threshold 0.3", 3, 2, "spam")
+        
+    
+    def test_threshold_too_small(self):
+        stdout, stderr = run("threshold.smi --compare topology --threshold -2.0", expect_sysexit=True)
+        self.assertTrue("--threshold: must be a value between 0.0 and 1.0, not -2.0" in stderr, stderr)
+
+    def test_threshold_too_large(self):
+        # Use "1.00000000000000000001" to check that the fraction.Fraction code is working
+        self.assertEqual(1.00000000000000000001, 1.0)
+        stdout, stderr = run("threshold.smi --compare topology --threshold 1.0000000000000000000000000001", expect_sysexit=True)
+        self.assertTrue("--threshold: must be a value between 0.0 and 1.0, not 1.0000000000" in stderr, stderr)
+
 
 if __name__ == "__main__":
     unittest.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.