Example #1
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')])))
Example #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'))
Example #3
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')})
Example #4
0
 def testIntersectionJsonld(self):
     t = Intersection([
         List([
             JR('a', graph={'@id': 'foo'}),
             JR('b', graph={'@id': 'bar'})
             ]),
         List([
             JR('b', graph={'@id': 'baz'}),
             JR('d', graph={'@id': 'foo'})
             ])])
     t = simplify(t)
     self.assertEqual(t, JR('e', graph={'@id': 'foo'}))
Example #5
0
 def testIntersectionTrivial(self):
     self.assertEqual(simplify(Intersection([])), Intersection([]))
     self.assertEqual(simplify(Intersection([R('a')])),
             R('a'))
Example #6
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')})
Example #7
0
 def testUnionTrivial(self):
     self.assertEqual(simplify(Union([])), List([]))
     self.assertEqual(simplify(Union([List([R('a')])])),
             R('a'))
Example #8
0
 def testList(self):
     self.assertEqual(simplify(List([R('a')])), R('a'))