From 16701547fd48ece9846046a0b2c4f60c5d69d109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Thu, 18 May 2017 00:51:16 +0100 Subject: [PATCH] Alter test attachment doc link mode This causes tests related to #75 to pass again --- pyzotero/zotero.py | 9 +++++++-- test/api_responses/attachments_doc.json | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pyzotero/zotero.py b/pyzotero/zotero.py index 7164686..2819837 100644 --- a/pyzotero/zotero.py +++ b/pyzotero/zotero.py @@ -204,8 +204,13 @@ def wrapped_f(self, *args, **kwargs): return retrieved.content # no need to do anything special, return JSON else: - return retrieved.json() - + # is this a snapshot though? + retr = retrieved.json() + # I know, I know + if isinstance(retr, dict) and retr.get('data', {}).get('linkMode', {}) == u"imported_url": + return retrieved.content + else: + return retr return wrapped_f diff --git a/test/api_responses/attachments_doc.json b/test/api_responses/attachments_doc.json index 09328dc..4c0ccb5 100644 --- a/test/api_responses/attachments_doc.json +++ b/test/api_responses/attachments_doc.json @@ -37,7 +37,7 @@ "itemType": "attachment", "title": "1641 Depositions", "accessDate": "2012-01-11T19:54:47Z", - "linkMode": "imported_url", + "linkMode": "idk", "charset": "utf-8", "relations": {}, "filename": "project-conservation.html",