def test_strkey(self): rel = ChildRelationship.create(klass=DictRelationship, parent=self.d, child=self.d['vegan'], param='vegan') result = rel.get_param_repr() assert result == "['vegan']"
def setup_class(cls): # Test data cls.custom1 = CustomClass(a='very long text here', b=37) cls.custom2 = CustomClass(a=313, b=37) cls.t1 = {42: 'answer', 'vegan': 'for life', 1337: cls.custom1} cls.t2 = { 42: 'answer', 'vegan': 'for the animals', 1337: cls.custom2 } # Manually build diff, bottom up cls.lowest = DiffLevel( cls.custom1.a, cls.custom2.a, report_type='values_changed') # Test manual child relationship rel_int_low_t1 = AttributeRelationship( parent=cls.custom1, child=cls.custom1.a, param="a") rel_int_low_t2 = AttributeRelationship( parent=cls.custom2, child=cls.custom2.a, param="a") cls.intermediate = DiffLevel( cls.custom1, cls.custom2, down=cls.lowest, child_rel1=rel_int_low_t1, child_rel2=rel_int_low_t2) cls.lowest.up = cls.intermediate # Test automatic child relationship t1_child_rel = ChildRelationship.create( klass=DictRelationship, parent=cls.t1, child=cls.intermediate.t1, param=1337) t2_child_rel = ChildRelationship.create( klass=DictRelationship, parent=cls.t2, child=cls.intermediate.t2, param=1337) cls.highest = DiffLevel( cls.t1, cls.t2, down=cls.intermediate, child_rel1=t1_child_rel, child_rel2=t2_child_rel) cls.intermediate.up = cls.highest
def test_strkey(self): rel = ChildRelationship.create( klass=DictRelationship, parent=self.d, child=self.d['vegan'], param='vegan') result = rel.get_param_repr() assert result == "['vegan']"
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_max(self): rel = ChildRelationship.create(SubscriptableIterableRelationship, self.l, self.custom, 2) assert rel.get_param_repr() == "[2]"
def test_create_invalid_klass(self): with pytest.raises(TypeError): ChildRelationship.create(DiffLevel, "hello", 42)