Ejemplo n.º 1
0
    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')]))]))
Ejemplo n.º 2
0
 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')])),
             ])),
         ]),
     )
Ejemplo n.º 3
0
 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')])),
             ])),
         ]),
     )
Ejemplo n.º 4
0
 def test(self):
     with reqs_eq_patcher():
         self.assertEqual(
             read("""
             { hello }
             """),
             Edge([Field('hello')]),
         )
Ejemplo n.º 5
0
    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')]))]))
Ejemplo n.º 6
0
    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')]))]))
Ejemplo n.º 7
0
 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')]))]),
         )
Ejemplo n.º 8
0
 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')]))]))]),
     )
Ejemplo n.º 9
0
 def __init__(self):
     self._stack = [Edge([])]
Ejemplo n.º 10
0
 def testLinkField(self):
     self.assertRequires(
         S.x1.a,
         Edge([Link('x1', Edge([Field('a')]))]),
     )
Ejemplo n.º 11
0
 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')]))
Ejemplo n.º 12
0
 def testEdgeLinkField(self):
     self.assertRequires(
         S.y.x1.b,
         Edge([Link('y', Edge([Link('x1', Edge([Field('b')]))]))]),
     )
Ejemplo n.º 13
0
 def testEachLinkField(self):
     self.assertRequires(
         each(S.item, S.xs, S.item.a),
         Edge([Link('xs', Edge([Field('a')]))]),
     )
Ejemplo n.º 14
0
 def testEdgeEachLinkField(self):
     self.assertRequires(
         each(S.item, S.y.xs, S.item.b),
         Edge([Link('y', Edge([Link('xs', Edge([Field('b')]))]))]),
     )
Ejemplo n.º 15
0
 def testField(self):
     self.assertReq(NamedRef(None, 'f', Env.f),
                    Edge([Field('f')]))
Ejemplo n.º 16
0
 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')]))]),
     )
Ejemplo n.º 17
0
 def testField(self):
     self.assertRequires(S.f, Edge([Field('f')]))
Ejemplo n.º 18
0
 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')]))]))]),
     )