Add skipped test for importing related items from Zotero RDF
This is hard to do currently because the natural place to do it (and where the previous seeAlso stuff was done) is translate_item.js, but with async import translators that now only gets one item at a time, whereas saving item relations requires all items to be saved. So this would probably need to be done in the import code in translate.js. It might also require undoing https://github.com/zotero/zotero/pull/453 so that getResourceURI() works on notes and figuring out another solution for the problem that was trying to solve.
This commit is contained in:
parent
c8fb2ecd1f
commit
9c2d0d7272
2 changed files with 58 additions and 0 deletions
32
test/tests/data/zotero_rdf.xml
Normal file
32
test/tests/data/zotero_rdf.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<rdf:RDF
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:z="http://www.zotero.org/namespaces/export#"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:bib="http://purl.org/net/biblio#">
|
||||
<bib:Book rdf:about="urn:isbn:1-4214-0283-1">
|
||||
<z:itemType>book</z:itemType>
|
||||
<dcterms:isReferencedBy rdf:resource="#item_4"/>
|
||||
<dcterms:isReferencedBy rdf:resource="#item_5"/>
|
||||
<dc:relation rdf:resource="http://example.com"/>
|
||||
<dc:identifier>ISBN 1-4214-0283-1</dc:identifier>
|
||||
<dc:title>A</dc:title>
|
||||
</bib:Book>
|
||||
<bib:Memo rdf:about="#item_4">
|
||||
<rdf:value>C</rdf:value><dc:relation rdf:resource="#item_5"/>
|
||||
</bib:Memo>
|
||||
<bib:Memo rdf:about="#item_5">
|
||||
<rdf:value>D</rdf:value><dc:relation rdf:resource="#item_4"/>
|
||||
</bib:Memo>
|
||||
<bib:Document rdf:about="http://example.com">
|
||||
<z:itemType>webpage</z:itemType>
|
||||
<dcterms:isPartOf>
|
||||
<z:Website></z:Website>
|
||||
</dcterms:isPartOf>
|
||||
<dc:relation rdf:resource="urn:isbn:1-4214-0283-1"/>
|
||||
<dc:identifier>
|
||||
<dcterms:URI><rdf:value>http://example.com</rdf:value></dcterms:URI>
|
||||
</dc:identifier>
|
||||
<dc:title>B</dc:title>
|
||||
</bib:Document>
|
||||
</rdf:RDF>
|
|
@ -68,5 +68,31 @@ describe("Import/Export", function () {
|
|||
'#item_' + note1.id
|
||||
);
|
||||
});
|
||||
|
||||
// Not currently supported
|
||||
it.skip("should import related items", async function () {
|
||||
var libraryID = Zotero.Libraries.userLibraryID;
|
||||
var file = OS.Path.join(getTestDataDirectory().path, 'zotero_rdf.xml');
|
||||
translation = new Zotero.Translate.Import();
|
||||
translation.setLocation(Zotero.File.pathToFile(file));
|
||||
let translators = await translation.getTranslators();
|
||||
translation.setTranslator(translators[0]);
|
||||
var newItems = await translation.translate({ libraryID });
|
||||
assert.lengthOf(newItems, 2); // DEBUG: why aren't child items returned here?
|
||||
// Parent item
|
||||
assert.lengthOf(newItems[0].relatedItems, 1);
|
||||
assert.lengthOf(newItems[1].relatedItems, 1);
|
||||
assert.sameMembers(newItems[0].relatedItems, [newItems[1]]);
|
||||
assert.sameMembers(newItems[1].relatedItems, [newItems[0]]);
|
||||
|
||||
var notes = newItems[0].getNotes();
|
||||
assert.lengthOf(notes, 2);
|
||||
var newNote1 = Zotero.Items.get(notes[0]);
|
||||
var newNote2 = Zotero.Items.get(notes[1]);
|
||||
assert.lengthOf(newNote1.relatedItems, 1);
|
||||
assert.lengthOf(newNote2.relatedItems, 1);
|
||||
assert.sameMembers(newNote1.relatedItems, [newNote2]);
|
||||
assert.sameMembers(newNote2.relatedItems, [newNote1]);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue