Exemplo n.º 1
0
 def testConstruction(self):
     """Test that DrugProblem objects constructed with certain params 
     have the expected values."""
     problem, count, ratio = self.atenolol[0]
     dp = drug_problem_kb.ProblemRelation(problem, count, ratio)
     self.assertTrue(isinstance(dp, drug_problem_kb.ProblemRelation))
     self.assertEqual(dp.name, problem)
     self.assertEqual(dp.patient_count, count)
     self.assertEqual(dp.ratio, ratio)
Exemplo n.º 2
0
 def testSorting(self):
     """Test ProblemRelation sorting: by ratio desc, patient_count desc, name asc"""
     atenolol1 = self.atenolol[1]
     atenolol2 = self.atenolol[2]
     atenolol3 = self.atenolol[3]
     atenolol4 = self.atenolol[4]
     # Manually sorted correctly to function as the baseline
     baseline = [
         drug_problem_kb.ProblemRelation(*atenolol1),
         drug_problem_kb.ProblemRelation(*atenolol2),
         drug_problem_kb.ProblemRelation(*atenolol3),
         drug_problem_kb.ProblemRelation(*atenolol4),
     ]
     testdata = [
         drug_problem_kb.ProblemRelation(*atenolol3),
         drug_problem_kb.ProblemRelation(*atenolol1),
         drug_problem_kb.ProblemRelation(*atenolol4),
         drug_problem_kb.ProblemRelation(*atenolol2),
     ]
     testdata.sort()
     self.assertEqual(baseline, testdata)
Exemplo n.º 3
0
 def testEqualityFalse4(self):
     """Drug/problem objects with the same patient counts and ratio
     but different problem name should not be equal."""
     dp1 = drug_problem_kb.ProblemRelation(*self.naproxen[0])
     dp2 = drug_problem_kb.ProblemRelation(*self.naproxen[3])
     self.assertNotEqual(dp1, dp2)
Exemplo n.º 4
0
 def testEqualityFalse1(self):
     """Drug/problem objects with the same problem name but different 
     patient counts & ratios should not be equal."""
     dp1 = drug_problem_kb.ProblemRelation(*self.atenolol[0])
     dp2 = drug_problem_kb.ProblemRelation(*self.atenolol[1])
     self.assertNotEqual(dp1, dp2)
Exemplo n.º 5
0
 def testEqualityTrue(self):
     """Drug/problem objects with the same problem name, patient counts,
     & ratios should be equal."""
     dp1 = drug_problem_kb.ProblemRelation(*self.stenosis[0])
     dp2 = drug_problem_kb.ProblemRelation(*self.stenosis[0])
     self.assertEqual(dp1, dp2)