summaryrefslogtreecommitdiff
path: root/tests/functional-tests/15-statistics.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional-tests/15-statistics.py')
-rwxr-xr-xtests/functional-tests/15-statistics.py98
1 files changed, 50 insertions, 48 deletions
diff --git a/tests/functional-tests/15-statistics.py b/tests/functional-tests/15-statistics.py
index 89efc3d77..0c36425d9 100755
--- a/tests/functional-tests/15-statistics.py
+++ b/tests/functional-tests/15-statistics.py
@@ -33,96 +33,98 @@ RDFS_RESOURCE = "rdfs:Resource"
NIE_IE = "nie:InformationElement"
RDFS_CLASS = "rdfs:Class"
+
class TrackerStoreStatisticsTests (CommonTrackerStoreTest):
+
"""
Check initial statistics, add, remove, update content and check results stats
"""
- def __get_stats (self):
+
+ def __get_stats(self):
results = {}
- for classname, count in self.tracker.get_stats ():
- results [str(classname)] = int(count)
+ for classname, count in self.tracker.get_stats():
+ results[str(classname)] = int(count)
return results
- def setUp (self):
+ def setUp(self):
"""
Each test append to this list the used URIS, so they can be removed
in the tearDown
"""
self.clean_up_instances = []
- def tearDown (self):
+ def tearDown(self):
for uri in self.clean_up_instances:
- self.tracker.update ("DELETE { <%s> a rdfs:Resource. }" % (uri))
+ self.tracker.update("DELETE { <%s> a rdfs:Resource. }" % (uri))
self.clean_up_instances = []
- time.sleep (1)
-
- def test_stats_01_insert_base_class (self):
- self.clean_up_instances.append ("test://stats-01")
-
- old_stats = self.__get_stats ()
- self.tracker.update ("INSERT { <test://stats-01> a nie:InformationElement. }")
- new_stats = self.__get_stats ()
+ time.sleep(1)
+
+ def test_stats_01_insert_base_class(self):
+ self.clean_up_instances.append("test://stats-01")
+
+ old_stats = self.__get_stats()
+ self.tracker.update(
+ "INSERT { <test://stats-01> a nie:InformationElement. }")
+ new_stats = self.__get_stats()
increased_classes = [NIE_IE, RDFS_RESOURCE]
- for k, v in new_stats.iteritems ():
+ for k, v in new_stats.iteritems():
if k in increased_classes:
- self.assertEquals (old_stats[k]+1, new_stats[k])
+ self.assertEquals(old_stats[k] + 1, new_stats[k])
else:
- self.assertEquals (old_stats [k], new_stats [k],
- "Class %s should have the same instances" % k)
+ self.assertEquals(old_stats[k], new_stats[k],
+ "Class %s should have the same instances" % k)
+ def test_stats_02_insert_deep_class(self):
+ self.clean_up_instances.append("test://stats-02")
+ old_stats = self.__get_stats()
+ self.tracker.update("INSERT { <test://stats-02> a nmm:Photo. }")
+ new_stats = self.__get_stats()
- def test_stats_02_insert_deep_class (self):
- self.clean_up_instances.append ("test://stats-02")
- old_stats = self.__get_stats ()
- self.tracker.update ("INSERT { <test://stats-02> a nmm:Photo. }")
- new_stats = self.__get_stats ()
-
- increased_classes = [ NIE_IE, RDFS_RESOURCE]
+ increased_classes = [NIE_IE, RDFS_RESOURCE]
new_classes = ["nmm:Photo", "nfo:Visual", "nfo:Image", "nfo:Media"]
# There were no instances of those classes before, check they are now
for c in new_classes:
- self.assertIn (c, new_stats)
-
- for k, v in new_stats.iteritems ():
+ self.assertIn(c, new_stats)
+
+ for k, v in new_stats.iteritems():
if k in increased_classes:
- self.assertEquals (old_stats [k]+1, new_stats[k])
+ self.assertEquals(old_stats[k] + 1, new_stats[k])
elif k in new_classes:
# This classes could exists previous or not!
- if old_stats.has_key (k):
- self.assertEquals (old_stats [k]+1, new_stats [k])
+ if old_stats.has_key(k):
+ self.assertEquals(old_stats[k] + 1, new_stats[k])
else:
- self.assertEquals (new_stats [k], 1)
+ self.assertEquals(new_stats[k], 1)
else:
- self.assertEquals (old_stats [k], new_stats[k])
+ self.assertEquals(old_stats[k], new_stats[k])
- def test_stats_03_delete_deep_class (self):
- self.clean_up_instances.append ("test://stats-03")
- self.tracker.update ("INSERT { <test://stats-03> a nmm:Photo. }")
+ def test_stats_03_delete_deep_class(self):
+ self.clean_up_instances.append("test://stats-03")
+ self.tracker.update("INSERT { <test://stats-03> a nmm:Photo. }")
- old_stats = self.__get_stats ()
- self.tracker.update ("DELETE { <test://stats-03> a rdfs:Resource. }")
- new_stats = self.__get_stats ()
+ old_stats = self.__get_stats()
+ self.tracker.update("DELETE { <test://stats-03> a rdfs:Resource. }")
+ new_stats = self.__get_stats()
decreased_classes = [NIE_IE, RDFS_RESOURCE]
# These classes could have no instance
- no_instances_classes = ["nmm:Photo", "nfo:Visual", "nfo:Image", "nfo:Media"]
+ no_instances_classes = [
+ "nmm:Photo", "nfo:Visual", "nfo:Image", "nfo:Media"]
for c in no_instances_classes:
if (old_stats[c] == 1):
- self.assertNotIn (c, new_stats)
+ self.assertNotIn(c, new_stats)
else:
- self.assertEquals (old_stats[c]-1, new_stats[c])
+ self.assertEquals(old_stats[c] - 1, new_stats[c])
- for k, v in new_stats.iteritems ():
+ for k, v in new_stats.iteritems():
if k in decreased_classes:
- self.assertEquals (old_stats [k]-1, new_stats[k])
+ self.assertEquals(old_stats[k] - 1, new_stats[k])
else:
- self.assertEquals (old_stats [k], new_stats [k])
+ self.assertEquals(old_stats[k], new_stats[k])
if __name__ == "__main__":
- ut.main ()
-
-
+ ut.main()