def test_subjects(self): collection = RDFCollection() self.assertIsNotNone(collection) collection.add_entity("MONKEY", "legs", "2") collection.add_entity("ZEBRA", "legs", "4") subjects = collection.subjects() self.assertEquals(2, len(subjects)) self.assertTrue("MONKEY" in subjects) self.assertTrue("ZEBRA" in subjects)
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_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)
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'))