[tracker-miners/tracker-miners-2.2: 17/47] functional-tests/410-extractor-decorator: Ensure data is deleted even if test fails
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/tracker-miners-2.2: 17/47] functional-tests/410-extractor-decorator: Ensure data is deleted even if test fails
- Date: Mon, 5 Aug 2019 15:48:30 +0000 (UTC)
commit aa0801549cafef69cd1f130745449201d24ce79a
Author: Sam Thursfield <sam afuera me uk>
Date: Sat Jun 22 19:22:25 2019 +0200
functional-tests/410-extractor-decorator: Ensure data is deleted even if test fails
tests/functional-tests/410-extractor-decorator.py | 49 ++++++++++++-----------
1 file changed, 26 insertions(+), 23 deletions(-)
---
diff --git a/tests/functional-tests/410-extractor-decorator.py
b/tests/functional-tests/410-extractor-decorator.py
index f523dd6ef..a5f3050dc 100755
--- a/tests/functional-tests/410-extractor-decorator.py
+++ b/tests/functional-tests/410-extractor-decorator.py
@@ -80,29 +80,32 @@ class ExtractorDecoratorTest(ut.TestCase):
# Insert a valid file and wait extraction of its metadata.
file_path = os.path.join(self.datadir, os.path.basename(VALID_FILE))
shutil.copy(VALID_FILE, file_path)
- file_id, file_urn = store.await_resource_inserted(
- VALID_FILE_CLASS, title=VALID_FILE_TITLE)
-
- # Remove a key piece of metadata.
- store.update(
- 'DELETE { <%s> nie:title ?title }'
- ' WHERE { <%s> nie:title ?title }' % (file_urn, file_urn))
- store.await_property_changed(VALID_FILE_CLASS, file_id, 'nie:title')
- assert not store.ask('ASK { <%s> nie:title ?title }' % file_urn)
-
- log("Sending re-index request")
- # Request re-indexing (same as `tracker index --file ...`)
- miner_fs.index_file('file://' + os.path.join(self.datadir, file_path))
-
- # The extractor should reindex the file and re-add the metadata that we
- # deleted, so we should see the nie:title property change.
- store.await_property_changed(VALID_FILE_CLASS, file_id, 'nie:title')
-
- title_result = store.query('SELECT ?title { <%s> nie:title ?title }' % file_urn)
- assert len(title_result) == 1
- self.assertEqual(title_result[0][0], VALID_FILE_TITLE)
-
- os.remove(file_path)
+ try:
+ file_id, file_urn = store.await_resource_inserted(
+ VALID_FILE_CLASS, title=VALID_FILE_TITLE)
+
+ # Remove a key piece of metadata.
+ # (Writeback must be disabled in the config so that the file
+ # itself is not changed).
+ store.update(
+ 'DELETE { <%s> nie:title ?title }'
+ ' WHERE { <%s> nie:title ?title }' % (file_urn, file_urn))
+ store.await_property_changed(VALID_FILE_CLASS, file_id, 'nie:title')
+ assert not store.ask('ASK { <%s> nie:title ?title }' % file_urn)
+
+ log("Sending re-index request")
+ # Request re-indexing (same as `tracker index --file ...`)
+ miner_fs.index_file('file://' + os.path.join(self.datadir, file_path))
+
+ # The extractor should reindex the file and re-add the metadata that we
+ # deleted, so we should see the nie:title property change.
+ store.await_property_changed(VALID_FILE_CLASS, file_id, 'nie:title')
+
+ title_result = store.query('SELECT ?title { <%s> nie:title ?title }' % file_urn)
+ assert len(title_result) == 1
+ self.assertEqual(title_result[0][0], VALID_FILE_TITLE)
+ finally:
+ os.remove(file_path)
if __name__ == '__main__':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]