Mobrovac has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/327495 )
Change subject: Make ISBNs from requestFromISBN be in Arrays ...................................................................... Make ISBNs from requestFromISBN be in Arrays Previously, ISBN fields from requestFromISBN were being returned as Strings. This returns them as an Array of strings, consistent with how the ISBN field is returned from other sources Bug:T153310 Change-Id: I887e7ee04e87f8a7f83cca9a51d0e7a83d5fe573 --- M lib/Exporter.js M test/features/scraping/isbn.js 2 files changed, 12 insertions(+), 9 deletions(-) Approvals: Mobrovac: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/lib/Exporter.js b/lib/Exporter.js index 90df943..895e263 100644 --- a/lib/Exporter.js +++ b/lib/Exporter.js @@ -494,8 +494,11 @@ // Pointer for code clarity var citation = cr.response.body[0]; - // Set requested identifier as part of citation - if (cr.idType !== 'url' && !citation[cr.idType.toUpperCase()]) { + // Add isbn inside of an Array + if (cr.idType === 'isbn'){ + citation.ISBN = [cr.idValue]; + // Set other identifiers as part of citation + } else if (cr.idType !== 'url' && !citation[cr.idType.toUpperCase()]) { citation[cr.idType.toUpperCase()] = cr.idValue; } diff --git a/test/features/scraping/isbn.js b/test/features/scraping/isbn.js index 727d4ab..9f1ad09 100644 --- a/test/features/scraping/isbn.js +++ b/test/features/scraping/isbn.js @@ -33,7 +33,7 @@ assert.deepEqual(res.body[0].place, 'Sebastapool, Calif.', 'Unexpected value; expected Sebastapool, Calif., got ' + res.body[0].place); assert.deepEqual(res.body[0].edition, '1st ed.', 'Unexpected value; expected 1st ed., got ' + res.body[0].edition); assert.deepEqual(res.body[0].date, '2009-01-01', 'Unexpected value; expected 2009-01-01, got ' + res.body[0].date); - assert.deepEqual(!!res.body[0].ISBN, true, 'Missing ISBN'); + assert.isInArray(res.body[0].ISBN, '9780596519797'); assert.deepEqual(res.body[0].itemType, 'book', 'Wrong itemType; expected book, got ' + res.body[0].itemType); }); }); @@ -47,7 +47,7 @@ assert.deepEqual(res.body[0].author, [['J.K.', 'Rowling']], 'Unexpected value; expected [[\'J.K.\', \'Rowling\']] got ' + res.body[0].author); assert.deepEqual(res.body[0].place, 'New York, NY', 'Unexpected value; expected New York, NY, got ' + res.body[0].place); assert.deepEqual(res.body[0].edition, '1st American ed.', 'Unexpected value; expected 1st ed., got ' + res.body[0].edition); - assert.deepEqual(!!res.body[0].ISBN, true, 'Missing ISBN'); + assert.isInArray(res.body[0].ISBN, '9780439784542'); assert.deepEqual(res.body[0].itemType, 'book', 'Wrong itemType; expected book, got ' + res.body[0].itemType); }); }); @@ -62,7 +62,7 @@ assert.deepEqual(res.body[0].publisher, 'DK Pub.', 'Unexpected value; expected DK Pub., got ' + res.body[0].publisher); assert.deepEqual(res.body[0].place, 'New York', 'Unexpected value; expected New York, got ' + res.body[0].place); assert.deepEqual(res.body[0].date, '2010-01-01', 'Unexpected value; expected 2010-01-01, got ' + res.body[0].date); - assert.deepEqual(!!res.body[0].ISBN, true, 'Missing ISBN'); + assert.isInArray(res.body[0].ISBN, '9780756662967'); assert.deepEqual(res.body[0].itemType, 'book', 'Wrong itemType; expected book, got ' + res.body[0].itemType); }); }); @@ -95,7 +95,7 @@ //assert.deepEqual(res.body[0].place, 'Sebastapool, Calif.', 'Unexpected value; expected Sebastapool, Calif., got ' + res.body[0].place); // Not currently working with Worldcat Search API - not present in results //assert.deepEqual(res.body[0].edition, '1st ed.', 'Unexpected value; expected 1st ed., got ' + res.body[0].edition); // Not currently working with Worldcat Search API - present in description tag assert.deepEqual(res.body[0].date, '2009-01-01', 'Unexpected value; expected 2009-01-01, got ' + res.body[0].date); - assert.deepEqual(!!res.body[0].ISBN, true, 'Missing ISBN'); + assert.isInArray(res.body[0].ISBN, '9780596519797'); assert.deepEqual(res.body[0].itemType, 'book', 'Wrong itemType; expected book, got ' + res.body[0].itemType); }); }); @@ -110,7 +110,7 @@ assert.deepEqual(res.body[0].studio, 'DK Pub', 'Unexpected value; expected DK Pub, got ' + res.body[0].studio); //assert.deepEqual(res.body[0].place, 'New York', 'Unexpected value; expected New York, got ' + res.body[0].place); //assert.deepEqual(res.body[0].date, '2010-01-01', 'Unexpected value; expected 2010-01-01, got ' + res.body[0].date); // Not currently working with worldcat; date is returned to us as '2010, ©1996' - assert.deepEqual(!!res.body[0].ISBN, true, 'Missing ISBN'); + assert.isInArray(res.body[0].ISBN, '9780756662967'); assert.deepEqual(res.body[0].itemType, 'videoRecording', 'Wrong itemType; expected videoRecording, got ' + res.body[0].itemType); }); }); @@ -124,7 +124,7 @@ assert.deepEqual(!!res.body[0].contributor, true, 'Missing contributor'); assert.deepEqual(res.body[0].studio, 'Universal', 'Unexpected value; expected Universal, got ' + res.body[0].studio); assert.deepEqual(res.body[0].date, '2000-01-01', 'Unexpected value; expected 2000-01-01, got ' + res.body[0].date); - assert.deepEqual(!!res.body[0].ISBN, true, 'Missing ISBN'); + assert.isInArray(res.body[0].ISBN, '9780783244396'); assert.deepEqual(res.body[0].itemType, 'videoRecording', 'Wrong itemType; expected videoRecording, got ' + res.body[0].itemType); }); }); @@ -138,7 +138,7 @@ assert.deepEqual(!!res.body[0].contributor, true, 'Missing contributor'); //assert.deepEqual(res.body[0].place, 'New York, NY', 'Unexpected value; expected New York, NY, got ' + res.body[0].place); //assert.deepEqual(res.body[0].edition, '1st American ed.', 'Unexpected value; expected 1st ed., got ' + res.body[0].edition); - assert.deepEqual(!!res.body[0].ISBN, true, 'Missing ISBN'); + assert.isInArray(res.body[0].ISBN, '9780439784542'); assert.deepEqual(res.body[0].itemType, 'book', 'Wrong itemType; expected book, got ' + res.body[0].itemType); }); }); -- To view, visit https://gerrit.wikimedia.org/r/327495 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I887e7ee04e87f8a7f83cca9a51d0e7a83d5fe573 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/services/citoid Gerrit-Branch: master Gerrit-Owner: Mvolz <mv...@wikimedia.org> Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org> Gerrit-Reviewer: Mvolz <mv...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits