summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-02-08 18:39:04 +0100
committerAleksander Morgado <aleksander@lanedo.com>2011-02-09 10:08:15 +0100
commit0ebadbd1d5488990f59e065ac1594b97068c47c0 (patch)
tree259a4111be4fbfe49444c54084bd90dc67ea529a
parent212485394fcf78da705057ded50df0ad4f35f5a3 (diff)
downloadtracker-0ebadbd1d5488990f59e065ac1594b97068c47c0.tar.gz
functional-tests: New insertion test to check that nie:url can't be duplicated
-rwxr-xr-xtests/functional-tests/01-insertion.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/functional-tests/01-insertion.py b/tests/functional-tests/01-insertion.py
index 8dc4085c5..2f5e869ca 100755
--- a/tests/functional-tests/01-insertion.py
+++ b/tests/functional-tests/01-insertion.py
@@ -379,6 +379,39 @@ class TrackerStoreInsertionTests (CommonTrackerStoreTest):
"""
self.__insert_invalid_date_test ("2004-05-06T1g:14:15-0200")
+ def test_insert_duplicated_url_01 (self):
+ """
+ 1. Insert a FileDataObject with a known nie:url, twice
+ """
+
+ url = "file:///some/magic/path/here"
+
+ insert = """
+ INSERT {
+ _:tag a nfo:FileDataObject;
+ nie:url '%s'.
+ }
+ """ % (url)
+
+ # First insert should go ok
+ self.tracker.update (insert)
+ # Second insert should not be ok
+ try:
+ self.tracker.update (insert)
+ except Exception:
+ pass
+
+ # Only 1 element must be available with the given nie:url
+ select = """
+ SELECT ?u WHERE { ?u nie:url \"%s\" }
+ """ % (url)
+ self.assertEquals (len (self.tracker.query (select)), 1)
+
+ # Cleanup
+ self.tracker.update ("""
+ DELETE { ?u a rdfs:Resource } WHERE { ?u a rdfs:Resource ; nie:url '%s' }
+ """ % (url))
+
class TrackerStoreDeleteTests (CommonTrackerStoreTest):
"""