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')])))
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 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')})
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'}))
def testIntersectionTrivial(self): self.assertEqual(simplify(Intersection([])), Intersection([])) self.assertEqual(simplify(Intersection([R('a')])), R('a'))
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')})
def testUnionTrivial(self): self.assertEqual(simplify(Union([])), List([])) self.assertEqual(simplify(Union([List([R('a')])])), R('a'))
def testList(self): self.assertEqual(simplify(List([R('a')])), R('a'))