Esempio n. 1
0
 def testUnionMixed(self):
     t = Union([List([R('a'), R('b')]), T(M(), M(), M())])
     t = simplify(t)
     self.assertIsInstance(t, Union)
     self.assertEqual(t.list[0], T(M(), M(), M()))
     self.assertIsInstance(t.list[1], List)
     self.assertEqual(set(t.list[1].list), {R('a'), R('b')})
Esempio n. 2
0
 def testIntersectionMixed(self):
     t = Intersection([List([R('a'), R('b')]), List([R('c'), R('a')]),
                      T(M(), M(), M())])
     t = simplify(t)
     self.assertIsInstance(t, Intersection)
     self.assertEqual(t.list[0], T(M(), M(), M()))
     self.assertEqual(t.list[1], R('a'))
def predicate(node):
    if node == T(M(), M(), M()):
        return R('foo')
    elif node == R('foo'):
        return R('bar')
    elif node == M():
        return node
    elif node == L([]):
        return node
    else:
        assert False, node
 def testWorking(self):
     t = T(M(), M(), M())
     q = {
         'id': '1',
         'language': 'en',
         'tree': t.as_dict(),
         'measures': {},
         'trace': []
     }
     self.assertResponse(
         q,
         [Response('en', R('bar'), {}, [TraceItem('test', R('bar'), {})])])
Esempio n. 5
0
 def testIntersectionResourceLists(self):
     t = Intersection([List([R('a'), R('b')]), List([R('c'), R('a')])])
     t = simplify(t)
     self.assertEqual(t, R('a'))
     t = Intersection([List([R('a'), R('b'), R('c')]), List([R('c'), R('a')])])
     t = simplify(t)
     self.assertIn(t, (List([R('a'), R('c')]), List([R('c'), R('a')])))
Esempio n. 6
0
 def testIntersectionTrivial(self):
     self.assertEqual(simplify(Intersection([])), Intersection([]))
     self.assertEqual(simplify(Intersection([R('a')])),
             R('a'))
Esempio n. 7
0
 def testUnionResourceLists(self):
     t = Union([List([R('a'), R('b')]), List([R('c')])])
     t = simplify(t)
     self.assertIsInstance(t, List)
     self.assertEqual(set(t.list), {R('a'), R('b'), R('c')})
Esempio n. 8
0
 def testUnionTrivial(self):
     self.assertEqual(simplify(Union([])), List([]))
     self.assertEqual(simplify(Union([List([R('a')])])),
             R('a'))
Esempio n. 9
0
 def testList(self):
     self.assertEqual(simplify(List([R('a')])), R('a'))