def test_add_collection_with_rdfstore_entityid(self): collection = RDFCollection() self.assertIsNotNone(collection) collection.add_entity("ACCOUNT", "hasSize", "0", "BANKING", rdf_store="file", entityid="1") 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.assertFalse(collection.has_object('ACCOUNTX', 'hasSize', "0")) self.assertFalse(collection.has_object('ACCOUNT', 'hasSizeX', "0")) self.assertFalse(collection.has_object('ACCOUNT', 'hasSize', "§")) self.assertEquals("file", collection.storename("BANKING")) self.assertEquals("BANKING", collection.entities_to_stores["ACCOUNT"]) entities = collection.entities_to_ids["1"] self.assertIsNotNone(entities) self.assertEquals(1, len(entities)) self.assertEquals({'HASSIZE': ['0', '0']}, entities[0].predicates)
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"))
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"))
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'))