예제 #1
0
    def test_add_collection(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        collection.add_entity("ACCOUNT", "hasSize", "0", "BANKING")
        self.assertTrue(collection.has_subject('ACCOUNT'))
        self.assertTrue(collection.has_predicate('ACCOUNT', 'hasSize'))
        self.assertTrue(collection.has_object('ACCOUNT', 'hasSize', "0"))
        self.assertIsNone(collection.storename("BANKING"))

        self.assertFalse(collection.has_object('ACCOUNTX', 'hasSize', "0"))
        self.assertFalse(collection.has_object('ACCOUNT', 'hasSizeX', "0"))
        self.assertFalse(collection.has_object('ACCOUNT', 'hasSize', "§"))

        self.assertEquals(['ACCOUNT'], collection.subjects())
        self.assertEquals(['HASSIZE'], collection.predicates('ACCOUNT'))
        self.assertEquals([], collection.predicates('ACCOUNTXX'))
        self.assertEquals([['0']], collection.objects('ACCOUNT', 'HASSIZE'))
        self.assertEquals([], collection.objects('ACCOUNT', 'HASSIZEXX'))
예제 #2
0
    def test_collection_others(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        collection.add_entity("ACCOUNT", "hasSize", "0", "BANKING", "BANIKING")
        self.assertTrue(collection.has_subject('ACCOUNT'))
        self.assertTrue(collection.has_predicate('ACCOUNT', 'hasSize'))
        self.assertTrue(collection.has_object('ACCOUNT', 'hasSize', "0"))

        self.assertIsNone(collection.storename("BANKING1"))
        self.assertEqual(0, len(collection.predicates("account1")))
        self.assertEqual(0, len(collection.objects("ACCOUNT1", "hasSize")))
        self.assertEqual(0, len(collection.objects("ACCOUNT", "hasSize1")))
        self.assertFalse(collection.has_object("ACCOUNT", "hasSize", "1"))
예제 #3
0
    def test_properties(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.assertEquals({}, collection.entities)
        self.assertEquals({}, collection.entities_to_ids)
        self.assertEquals({}, collection.stores)
        self.assertEquals({}, collection.entities_to_stores)

        self.assertEquals([], collection.subjects())
        self.assertEquals([], collection.predicates('ACCOUNT'))
        self.assertEquals([], collection.objects('ACCOUNT', 'HASSIZE'))

        self.assertIsNone(collection.storename("BANKING"))
예제 #4
0
    def test_objects(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        collection.add_entity("MONKEY", "legs", "2")
        collection.add_entity("MONKEY", "hasFur", "true")
        collection.add_entity("ZEBRA", "legs", "4")
        collection.add_entity("BIRD", "legs", "2")
        collection.add_entity("ELEPHANT", "trunk", "true")

        subjects = collection.subjects()
        self.assertEquals(4, len(subjects))

        object = collection.objects(subject="MONKEY", predicate="legs")
        self.assertEqual(["2"], object)