def setUp(self): # Test data self.custom1 = CustomClass(a='very long text here', b=37) self.custom2 = CustomClass(a=313, b=37) self.t1 = {42: 'answer', 'vegan': 'for life', 1337: self.custom1} self.t2 = { 42: 'answer', 'vegan': 'for the animals', 1337: self.custom2 } # Manually build diff, bottom up self.lowest = DiffLevel(self.custom1.a, self.custom2.a, report_type='values_changed') # Test manual child relationship rel_int_low_t1 = AttributeRelationship(parent=self.custom1, child=self.custom1.a, param="a") rel_int_low_t2 = AttributeRelationship(parent=self.custom2, child=self.custom2.a, param="a") self.intermediate = DiffLevel(self.custom1, self.custom2, down=self.lowest, child_rel1=rel_int_low_t1, child_rel2=rel_int_low_t2) self.lowest.up = self.intermediate # Test automatic child relationship t1_child_rel = ChildRelationship.create(klass=DictRelationship, parent=self.t1, child=self.intermediate.t1, param=1337) t2_child_rel = ChildRelationship.create(klass=DictRelationship, parent=self.t2, child=self.intermediate.t2, param=1337) self.highest = DiffLevel(self.t1, self.t2, down=self.intermediate, child_rel1=t1_child_rel, child_rel2=t2_child_rel) self.intermediate.up = self.highest
def test_get_param_from_obj(self): rel = AttributeRelationship(self.custom, 13, "a") assert rel.get_param_from_obj(self.custom) == 13
def test_a(self): rel = AttributeRelationship(self.custom, 13, "a") result = rel.get_param_repr() assert result == ".a"
def test_get_param_from_obj(self): rel = AttributeRelationship(self.custom, 13, "a") self.assertEqual(rel.get_param_from_obj(self.custom), 13)