Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move example JSON article for unit testing to separate file

  • Loading branch information...
commit 312e80160851fe5cc934276d3fde93b34b174ea8 1 parent 63e878f
@vtourraine vtourraine authored
View
12 Examples/SZNAltmetricDemoOSX/SZNAltmetricDemoOSX.xcodeproj/project.pbxproj
@@ -18,6 +18,7 @@
146301B6170AFC2F00220E31 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 146301B4170AFC2F00220E31 /* InfoPlist.strings */; };
146301B9170AFC2F00220E31 /* SZNAltmetricDemoOSXTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 146301B8170AFC2F00220E31 /* SZNAltmetricDemoOSXTests.m */; };
146301CA170B181500220E31 /* SZNAltmetricArticleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 146301C9170B181500220E31 /* SZNAltmetricArticleTests.m */; };
+ 14BA88CF17143FFB00FE3550 /* article.json in Resources */ = {isa = PBXBuildFile; fileRef = 14BA88CE17143FFB00FE3550 /* article.json */; };
BCB82FE188804C62B5E9BB63 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E540AFA3B454868865832E9 /* libPods.a */; };
/* End PBXBuildFile section */
@@ -53,6 +54,7 @@
146301B8170AFC2F00220E31 /* SZNAltmetricDemoOSXTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SZNAltmetricDemoOSXTests.m; path = classes/SZNAltmetricDemoOSXTests.m; sourceTree = "<group>"; };
146301C8170B181500220E31 /* SZNAltmetricArticleTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SZNAltmetricArticleTests.h; path = classes/SZNAltmetricArticleTests.h; sourceTree = "<group>"; };
146301C9170B181500220E31 /* SZNAltmetricArticleTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SZNAltmetricArticleTests.m; path = classes/SZNAltmetricArticleTests.m; sourceTree = "<group>"; };
+ 14BA88CE17143FFB00FE3550 /* article.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = article.json; path = resources/article.json; sourceTree = "<group>"; };
27909A7C6B334D3495B674BC /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = SOURCE_ROOT; };
8E540AFA3B454868865832E9 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -150,6 +152,7 @@
146301B8170AFC2F00220E31 /* SZNAltmetricDemoOSXTests.m */,
146301C8170B181500220E31 /* SZNAltmetricArticleTests.h */,
146301C9170B181500220E31 /* SZNAltmetricArticleTests.m */,
+ 14BA88D017143FFE00FE3550 /* Resources */,
146301B2170AFC2F00220E31 /* Supporting Files */,
);
path = SZNAltmetricDemoOSXTests;
@@ -164,6 +167,14 @@
name = "Supporting Files";
sourceTree = "<group>";
};
+ 14BA88D017143FFE00FE3550 /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ 14BA88CE17143FFB00FE3550 /* article.json */,
+ );
+ name = Resources;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -248,6 +259,7 @@
buildActionMask = 2147483647;
files = (
146301B6170AFC2F00220E31 /* InfoPlist.strings in Resources */,
+ 14BA88CF17143FFB00FE3550 /* article.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
60 Examples/SZNAltmetricDemoOSX/SZNAltmetricDemoOSXTests/classes/SZNAltmetricArticleTests.m
@@ -13,56 +13,38 @@ @implementation SZNAltmetricArticleTests
- (void)testArticleFromRespondeDictionary
{
- SZNAltmetricArticle *article = [SZNAltmetricArticle articleWithAPIResponseObject:@{
- @"added_on" : @(1324491937),
- @"altmetric_id" : @(1),
- @"ads_id" : @"ADS-123",
- @"cited_by_accounts_count" : @(393),
- @"cited_by_fbwalls_count" : @(12),
- @"cited_by_feeds_count" : @(2),
- @"cited_by_gplus_count" : @(20),
- @"cited_by_posts_count" : @(402),
- @"cited_by_tweeters_count" : @(359),
- @"doi" : @"DOI-123",
- @"arxiv_id" : @"arXiv-123",
- @"last_updated" : @(1324491938),
- @"nlmid" : @"NLM-123",
- @"pmid" : @"pmid-123",
- @"published_on" : @(1324491939),
- @"score" : @(42),
- @"images" : @{@"small" : @"http://test.com/small.jpg", @"medium" : @"http://test.com/medium.jpg", @"large" : @"http://test.com/large.jpg"},
- @"is_oa" : @(YES),
- @"journal": @"Jou",
- @"title" : @"Article",
- @"details_url" : @"http://test.com/article/details",
- @"url" : @"http://test.com/article"}];
+ NSData *JSONData = [NSData dataWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForResource:@"article" ofType:@"json"]];
+ NSError *JSONError = nil;
+ NSDictionary *JSONArticleDictionary = [NSJSONSerialization JSONObjectWithData:JSONData options:kNilOptions error:&JSONError];
+ SZNAltmetricArticle *article = [SZNAltmetricArticle articleWithAPIResponseObject:JSONArticleDictionary];
+ STAssertNil(JSONError, @"Article deserialization failed");
STAssertNotNil(article, @"Article not created");
STAssertEqualObjects(article.addedOn, [NSDate dateWithTimeIntervalSince1970:1324491937], @"Added on not extracted");
- STAssertEqualObjects(article.identifier, @"1", @"Identifier not extracted");
- STAssertEqualObjects(article.ADSBibcode, @"ADS-123", @"ADS not extracted");
+ STAssertEqualObjects(article.identifier, @"502878", @"Identifier not extracted");
+ STAssertEqualObjects(article.ADSBibcode, @"2011natur.480..426v", @"ADS not extracted");
STAssertEqualObjects(article.citedByAccountsCount, @(393), @"Cited by accounts not extracted");
STAssertEqualObjects(article.citedByFacebookWallsCount, @(12), @"Cited by Facebook walls not extracted");
STAssertEqualObjects(article.citedByFeedsCount, @(2), @"Cited by feeds not extracted");
STAssertEqualObjects(article.citedByGooglePlusCount, @(20), @"Cited by Google+ not extracted");
STAssertEqualObjects(article.citedByPostsCount, @(402), @"Cited by posts not extracted");
STAssertEqualObjects(article.citedByTweetersCount, @(359), @"Cited by tweeters not extracted");
- STAssertEqualObjects(article.DOI, @"DOI-123", @"DOI not extracted");
+ STAssertEqualObjects(article.DOI, @"10.1038/480426a", @"DOI not extracted");
STAssertEqualObjects(article.arXiv, @"arXiv-123", @"arXiv identifier not extracted");
- STAssertEqualObjects(article.lastUpdated, [NSDate dateWithTimeIntervalSince1970:1324491938], @"Last updated not extracted");
- STAssertEqualObjects(article.NLMIdentifier, @"NLM-123", @"NLM identifier not extracted");
- STAssertEqualObjects(article.pubMedIdentifier, @"pmid-123", @"PubMed identifier not extracted");
- STAssertEqualObjects(article.publishedOn, [NSDate dateWithTimeIntervalSince1970:1324491939], @"Published on not extracted");
- STAssertEqualObjects(article.score, @(42), @"Score not extracted");
- STAssertEqualObjects(article.imageSmallURL.absoluteString, @"http://test.com/small.jpg", @"Image small URL not extracted");
- STAssertEqualObjects(article.imageMediumURL.absoluteString, @"http://test.com/medium.jpg", @"Image medium URL not extracted");
- STAssertEqualObjects(article.imageLargeURL.absoluteString, @"http://test.com/large.jpg", @"Image large URL not extracted");
- STAssertEqualObjects(article.openAccess, @(YES), @"Open Access not extracted");
- STAssertEqualObjects(article.journal, @"Jou", @"Journal not extracted");
- STAssertEqualObjects(article.title, @"Article", @"Title not extracted");
- STAssertEqualObjects(article.articleURL.absoluteString, @"http://test.com/article", @"Article URL not extracted");
- STAssertEqualObjects(article.detailsURL.absoluteString, @"http://test.com/article/details", @"Details URL not extracted");
+ STAssertEqualObjects(article.lastUpdated, [NSDate dateWithTimeIntervalSince1970:1353885698], @"Last updated not extracted");
+ STAssertEqualObjects(article.NLMIdentifier, @"0410462", @"NLM identifier not extracted");
+ STAssertEqualObjects(article.pubMedIdentifier, @"22193080", @"PubMed identifier not extracted");
+ STAssertEqualObjects(article.publishedOn, [NSDate dateWithTimeIntervalSince1970:1324512000], @"Published on not extracted");
+ STAssertEqualObjects(article.score, @(353.626), @"Score not extracted");
+ STAssertEqualObjects(article.imageSmallURL.absoluteString, @"http://fastly.altmetric.com/?size=64&score=354&types=bfgttttt", @"Image small URL not extracted");
+ STAssertEqualObjects(article.imageMediumURL.absoluteString, @"http://fastly.altmetric.com/?size=100&score=354&types=bfgttttt", @"Image medium URL not extracted");
+ STAssertEqualObjects(article.imageLargeURL.absoluteString, @"http://fastly.altmetric.com/?size=180&score=354&types=bfgttttt", @"Image large URL not extracted");
+ STAssertEqualObjects(article.openAccess, @(NO), @"Open Access not extracted");
+ STAssertEqualObjects(article.journal, @"Nature", @"Journal not extracted");
+ STAssertEqualObjects(article.title, @"365 days: 2011 in review", @"Title not extracted");
+ STAssertEqualObjects(article.articleURL.absoluteString, @"http://www.nature.com/news/365-days-2011-in-review-1.9684", @"Article URL not extracted");
+ STAssertEqualObjects(article.detailsURL.absoluteString, @"http://www.altmetric.com/details.php?citation_id=502878", @"Details URL not extracted");
}
@end
View
49 Examples/SZNAltmetricDemoOSX/SZNAltmetricDemoOSXTests/resources/article.json
@@ -0,0 +1,49 @@
+{
+ "title":"365 days: 2011 in review",
+ "doi":"10.1038/480426a",
+ "pmid":"22193080",
+ "nlmid":"0410462",
+ "tq":[
+ "Take a look back at the year in science with our review of the biggest stories of 2011",
+ "Third: Our round-up of the year in research and science policy +interactive timeline",
+ "Nature's 'year in science' review is really rather essential @NatureNews",
+ "Scientific Paper Trail 2011 #HigherEd"],
+ "ads_id":"2011natur.480..426v",
+ "arxiv_id": "arXiv-123",
+ "altmetric_jid":"4f6fa62f3cf058f6100082d3",
+ "issns":[
+ "0028-0836",
+ "1744-7933"],
+ "journal":"Nature",
+ "cohorts":{"pub":164,"sci":166,"com":20,"doc":17},
+ "altmetric_id":502878,
+ "schema":"1.5.4",
+ "is_oa":false,
+ "cited_by_fbwalls_count":12,
+ "cited_by_feeds_count":2,
+ "cited_by_gplus_count":20,
+ "cited_by_posts_count":402,
+ "cited_by_tweeters_count":359,
+ "cited_by_accounts_count":393,
+ "context":{
+ "journal":{"count":252,"rank":12,"pct":96,"mean":107.40476190476,"median":58.8,"sample_size":252,"sparkline":[1521.466,199.758,142.2,109.2,80.65,58.8,45.75,36.518,26.75,9]},
+ "all":{"count":1076294,"rank":2,"pct":100,"mean":2.8677628974983,"median":1,"sample_size":10000,"sparkline":[1530.608,6.5,2.5,1.6,1,1,0.75,0.5,0.25,0.25]},
+ "similar_age_3m":{"count":97229,"rank":2,"pct":100,"mean":3.2396712914871,"median":1,"sample_size":10000,"sparkline":[378.86,6.672,2.5,1.5,1,1,0.5,0.5,0.25,0.25]},
+ "similar_age_journal_3m":{"count":90,"rank":2,"pct":98,"mean":97.577777777778,"median":57.8,"sample_size":90,"sparkline":[701.984,200.028,141,106.7,78.65,57.8,48.4,37.35,28.7,11.85]}
+ },
+ "score":353.626,
+ "history":{"1d":0,"2d":0,"3d":0,"4d":0,"5d":0,"6d":0,"1w":0,"1m":0,"3m":0,"6m":77.35,"1y":77.35,"at":353.626},
+ "url":"http://www.nature.com/news/365-days-2011-in-review-1.9684",
+ "added_on":1324491937,
+ "published_on":1324512000,
+ "subjects":["science"],
+ "scopus_subjects":[],
+ "last_updated":1353885698,
+ "readers_count":0,
+ "readers":{"mendeley":0,"connotea":0,"citeulike":0},
+ "images":{
+ "small":"http://fastly.altmetric.com/?size=64&score=354&types=bfgttttt",
+ "medium":"http://fastly.altmetric.com/?size=100&score=354&types=bfgttttt",
+ "large":"http://fastly.altmetric.com/?size=180&score=354&types=bfgttttt"},
+ "details_url":"http://www.altmetric.com/details.php?citation_id=502878"
+}
Please sign in to comment.
Something went wrong with that request. Please try again.