1. Andrew Dalke
  2. fmcs

Commits

Andrew Dalke  committed 0bbf300

Add test cases for the new threshold option

  • Participants
  • Parent commits b3a9f81
  • Branches default

Comments (0)

Files changed (1)

File tests/test_commandline.py

View file
  • Ignore whitespace
         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()