def testEdgeField(self): x_ref = NamedRef(None, 'x', Env.x) self.assertReq(x_ref, Edge([Link('x', Edge([]))])) a_ref = NamedRef(x_ref, 'a', Env.x.fields['a']) self.assertReq(a_ref, Edge([Link('x', Edge([Field('a')]))]))
def testList(self): self.assertRequires( each(S.item, S.ys, [foo(S.item.x1, S.item), bar(S.item)]), Edge([ Link('ys', Edge([ Field('d'), Field('e'), Field('f'), Link('x1', Edge([Field('a'), Field('b'), Field('c')])), ])), ]), )
def testDict(self): self.assertRequires( each(S.item, S.ys, {'foo-value': foo(S.item.x1, S.item), 'bar-value': bar(S.item)}), Edge([ Link('ys', Edge([ Field('d'), Field('e'), Field('f'), Link('x1', Edge([Field('a'), Field('b'), Field('c')])), ])), ]), )
def test(self): with reqs_eq_patcher(): self.assertEqual( read(""" { hello } """), Edge([Field('hello')]), )
def testLinkOneEdgeField(self): x1_ref = NamedRef(None, 'x1', Env.x1) self.assertReq(x1_ref, Edge([Link('x1', Edge([]))])) x_ref = Ref(x1_ref, Env.x) self.assertReq(x_ref, Edge([Link('x1', Edge([]))])) b_ref = NamedRef(x_ref, 'b', Env.x.fields['b']) self.assertReq(b_ref, Edge([Link('x1', Edge([Field('b')]))]))
def testLinkListEdgeField(self): xs_ref = NamedRef(None, 'xs', Env.xs) self.assertReq(xs_ref, Edge([Link('xs', Edge([]))])) x_ref = Ref(xs_ref, Env.x) self.assertReq(x_ref, Edge([Link('xs', Edge([]))])) c_ref = NamedRef(x_ref, 'c', Env.x.fields['c']) self.assertReq(c_ref, Edge([Link('xs', Edge([Field('c')]))]))
def test(self): with reqs_eq_patcher(): self.assertEqual( merge([ Edge([Field('a1'), Field('a2'), Link('b', Edge([Field('b1'), Field('b2')]))]), Edge([Field('a2'), Field('a3'), Link('b', Edge([Field('b2'), Field('b3')]))]), ]), Edge([Field('a1'), Field('a2'), Field('a3'), Link('b', Edge([Field('b1'), Field('b2'), Field('b3')]))]), )
def testTupleWithNestedLinkToMany(self): self.assertRequires( baz(S.y), Edge([Link('y', Edge([Field('e'), Link('xs', Edge([Field('b')]))]))]), ) self.assertRequires( each(S.item, S.ys, baz(S.item)), Edge([Link('ys', Edge([Field('e'), Link('xs', Edge([Field('b')]))]))]), )
def __init__(self): self._stack = [Edge([])]
def testLinkField(self): self.assertRequires( S.x1.a, Edge([Link('x1', Edge([Field('a')]))]), )
def testAddReq(self): self.assertReq(NamedRef(None, 'xs', Env.xs), Edge([Link('xs', Edge([Field('a'), Field('c')]))]), add_req=Edge([Field('a'), Field('c')]))
def testEdgeLinkField(self): self.assertRequires( S.y.x1.b, Edge([Link('y', Edge([Link('x1', Edge([Field('b')]))]))]), )
def testEachLinkField(self): self.assertRequires( each(S.item, S.xs, S.item.a), Edge([Link('xs', Edge([Field('a')]))]), )
def testEdgeEachLinkField(self): self.assertRequires( each(S.item, S.y.xs, S.item.b), Edge([Link('y', Edge([Link('xs', Edge([Field('b')]))]))]), )
def testField(self): self.assertReq(NamedRef(None, 'f', Env.f), Edge([Field('f')]))
def testTupleWithEdges(self): self.assertRequires( foo(S.x, S.y), Edge([Link('x', Edge([Field('a'), Field('c')])), Link('y', Edge([Field('d'), Field('f')]))]), )
def testField(self): self.assertRequires(S.f, Edge([Field('f')]))
def testTupleWithLinks(self): self.assertRequires( foo(S.x1, S.y1), Edge([Link('x1', Edge([Field('a'), Field('c')])), Link('y1', Edge([Field('d'), Field('f')]))]), ) self.assertRequires( each(S.item, S.xs, foo(S.item, S.y1)), Edge([Link('xs', Edge([Field('a'), Field('c')])), Link('y1', Edge([Field('d'), Field('f')]))]), ) self.assertRequires( each(S.item, S.ys, foo(S.x1, S.item)), Edge([Link('x1', Edge([Field('a'), Field('c')])), Link('ys', Edge([Field('d'), Field('f')]))]), ) self.assertRequires( each(S.item, S.ys, foo(S.item.x1, S.item)), Edge([Link('ys', Edge([Field('d'), Field('f'), Link('x1', Edge([Field('a'), Field('c')]))]))]), )