def test_definitions(self): e1 = Equation(full_name="Jon's Law") e1.save(no_wiki=True) v1 = Variable(full_name="Jon's Constant") v1.save(no_wiki=True) e1.add_defined_var(v1.full_name) self.assertEqual(e1.defined_var.full_name, v1.full_name)
def test_equation_add_variables(self): e1 = Equation(full_name="Jon's Law") e1.save(no_wiki=True) v1 = Variable(full_name="Jon's Constant") v1.save(no_wiki=True) v2 = Variable(full_name="Jon's Operator") v2.save(no_wiki=True) v3 = Variable(full_name="Jon's Plus Sign") v3.save(no_wiki=True) e1.add_defined_var("Jon's Constant") e1.add_variables("Jon's Constant,Jon's Operator,Jon's Plus Sign") self.assertEqual(e1.defined_var.full_name, v1.full_name) self.assertTrue(v2 in e1.variables.all()) self.assertTrue(v3 in e1.variables.all()) self.assertFalse(v1 in e1.variables.all())
except (ObjectDoesNotExist, MultipleObjectsReturned), e: raise AssertionError else: self.assertTrue(v1 in s1.variable_set.all()) self.assertTrue(s1 in v1.search_terms.all()) # now try adding a search term that it already has v1.add_SearchTerm("acc") try: s2 = SearchTerm.objects.get(term="acc") except (ObjectDoesNotExist, MultipleObjectsReturned), e: raise AssertionError else: self.assertEqual([x for x in s2.variable_set.all()], [v1]) self.assertTrue(s2 in v1.search_terms.all()) # now try adding the same search term to a different object e1 = Equation(full_name="Jon's Law") e1.save(no_wiki=True) e1.add_SearchTerm("acc") try: s3 = SearchTerm.objects.get(term="acc") except (ObjectDoesNotExist, MultipleObjectsReturned), e: raise AssertionError else: self.assertTrue(e1 in s3.equation_set.all()) self.assertTrue(s3 in e1.search_terms.all()) def test_infobase_add_from_sequence(self): v1 = Variable(full_name="acceleration") v1.save(no_wiki=True) u1 = Unit(full_name="ms") u1.save(no_wiki=True)