{"action":"created","comment":{"url":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/comments/31039594","id":31039594,"diff_hunk":"@@ -0,0 +1,79 @@\n+//\n+//  MusicSourceTests.m\n+//  SCloudRandomizer\n+//\n+//  Created by Asha Balasubramaniam on 5/14/15.\n+//  Copyright (c) 2015 Akshay Bharath. All rights reserved.\n+//\n+\n+#import <UIKit/UIKit.h>\n+#import <XCTest/XCTest.h>\n+#import <OCMock/OCMock.h>\n+#import <SCRequest.h>\n+#import <SCSoundCloud.h>\n+#import <SCAccount.h>\n+\n+#import \"MusicSource.h\"\n+#import \"SearchParams.h\"\n+#import \"Track.h\"\n+\n+@interface MusicSourceTests : XCTestCase\n+\n+@end\n+\n+@implementation MusicSourceTests\n+\n+- (void) testgettingRandomTracks {\n+    \n+    MusicSource *musicSource = [MusicSource getInstance];\n+    id partialMusicSourceMock = OCMPartialMock(musicSource);\n+    \n+    id mockedSCAccount = OCMClassMock([SCAccount class]);\n+    \n+    OCMStub([partialMusicSourceMock account]).andReturn(mockedSCAccount);\n+    \n+    NSString *keyword = @\"test\";\n+    SearchParams *searchParams = [[SearchParams alloc]\n+                                  initWithBool:YES\n+                                  keywords:keyword\n+                                  lowBpm:[NSNumber numberWithInt:10]\n+                                  highBpm:[NSNumber numberWithInt:30]];\n+    \n+    void (^stubbedResponseHandler)(NSInvocation *) = ^(NSInvocation *invocation) {\n+        NSString *mockedResponse = @\"[{ \\\"id\\\": 13158665, \\\"stream_url\\\": \\\"http://foo.com\\\" }]\";\n+        NSData *jsonData = [mockedResponse dataUsingEncoding:NSUTF8StringEncoding];\n+        \n+        // NOTE: Reason being [invocation getArgument] expects\n+        // a (void*) pointer and so ARC does not retain the reference for\n+        // responseHandler. Since we don't want a corresponding\n+        // release, adding __unsafe_unretained to avoid a over release\n+        // Source: http://stackoverflow.com/questions/13268502/exc-bad-access-when-accessing-parameters-in-anddo-of-ocmock\n+        __unsafe_unretained SCRequestResponseHandler responseHandler;\n+        \n+        [invocation getArgument:&responseHandler atIndex:7];\n+        \n+        responseHandler(nil, jsonData, nil);\n+    };\n+    \n+    NSString *resourceURL = [NSString stringWithFormat:@\"https://api.soundcloud.com/tracks?format=json&q=%@\", keyword];\n+    OCMStub([partialMusicSourceMock fetchTracks:SCRequestMethodGET","path":"SCloudRandomizerTests/MusicSourceTests.m","position":59,"original_position":59,"commit_id":"a84be667109ca0d65a4098ac99009bca5dd2d111","original_commit_id":"a84be667109ca0d65a4098ac99009bca5dd2d111","user":{"login":"VegaFromLyra","id":2251508,"avatar_url":"https://avatars.githubusercontent.com/u/2251508?v=3","gravatar_id":"","url":"https://api.github.com/users/VegaFromLyra","html_url":"https://github.com/VegaFromLyra","followers_url":"https://api.github.com/users/VegaFromLyra/followers","following_url":"https://api.github.com/users/VegaFromLyra/following{/other_user}","gists_url":"https://api.github.com/users/VegaFromLyra/gists{/gist_id}","starred_url":"https://api.github.com/users/VegaFromLyra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VegaFromLyra/subscriptions","organizations_url":"https://api.github.com/users/VegaFromLyra/orgs","repos_url":"https://api.github.com/users/VegaFromLyra/repos","events_url":"https://api.github.com/users/VegaFromLyra/events{/privacy}","received_events_url":"https://api.github.com/users/VegaFromLyra/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2015-05-26T14:38:08Z","updated_at":"2015-05-26T14:38:08Z","html_url":"https://github.com/akshay23/SCloudRandomizer/pull/15#discussion_r31039594","pull_request_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/comments/31039594"},"html":{"href":"https://github.com/akshay23/SCloudRandomizer/pull/15#discussion_r31039594"},"pull_request":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/15","id":35458728,"html_url":"https://github.com/akshay23/SCloudRandomizer/pull/15","diff_url":"https://github.com/akshay23/SCloudRandomizer/pull/15.diff","patch_url":"https://github.com/akshay23/SCloudRandomizer/pull/15.patch","issue_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues/15","number":15,"state":"open","locked":false,"title":"Unit tests!","user":{"login":"VegaFromLyra","id":2251508,"avatar_url":"https://avatars.githubusercontent.com/u/2251508?v=3","gravatar_id":"","url":"https://api.github.com/users/VegaFromLyra","html_url":"https://github.com/VegaFromLyra","followers_url":"https://api.github.com/users/VegaFromLyra/followers","following_url":"https://api.github.com/users/VegaFromLyra/following{/other_user}","gists_url":"https://api.github.com/users/VegaFromLyra/gists{/gist_id}","starred_url":"https://api.github.com/users/VegaFromLyra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VegaFromLyra/subscriptions","organizations_url":"https://api.github.com/users/VegaFromLyra/orgs","repos_url":"https://api.github.com/users/VegaFromLyra/repos","events_url":"https://api.github.com/users/VegaFromLyra/events{/privacy}","received_events_url":"https://api.github.com/users/VegaFromLyra/received_events","type":"User","site_admin":false},"body":"Added some simple unit tests for the utility methods\r\n\r\n### ToDo\r\n- [x] Add another unit test for MusicSource::getRandomTracks. Figuring how to mock out the sound cloud API\r\n- [ ] Add E2E test against the real API. This will be a separate PR","created_at":"2015-05-14T20:29:15Z","updated_at":"2015-05-26T14:38:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"532031ebff1c627725716eea4ab98c517f861038","assignee":{"login":"akshay23","id":7291663,"avatar_url":"https://avatars.githubusercontent.com/u/7291663?v=3","gravatar_id":"","url":"https://api.github.com/users/akshay23","html_url":"https://github.com/akshay23","followers_url":"https://api.github.com/users/akshay23/followers","following_url":"https://api.github.com/users/akshay23/following{/other_user}","gists_url":"https://api.github.com/users/akshay23/gists{/gist_id}","starred_url":"https://api.github.com/users/akshay23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akshay23/subscriptions","organizations_url":"https://api.github.com/users/akshay23/orgs","repos_url":"https://api.github.com/users/akshay23/repos","events_url":"https://api.github.com/users/akshay23/events{/privacy}","received_events_url":"https://api.github.com/users/akshay23/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/15/commits","review_comments_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/15/comments","review_comment_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues/15/comments","statuses_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/statuses/a84be667109ca0d65a4098ac99009bca5dd2d111","head":{"label":"akshay23:ab_Tests","ref":"ab_Tests","sha":"a84be667109ca0d65a4098ac99009bca5dd2d111","user":{"login":"akshay23","id":7291663,"avatar_url":"https://avatars.githubusercontent.com/u/7291663?v=3","gravatar_id":"","url":"https://api.github.com/users/akshay23","html_url":"https://github.com/akshay23","followers_url":"https://api.github.com/users/akshay23/followers","following_url":"https://api.github.com/users/akshay23/following{/other_user}","gists_url":"https://api.github.com/users/akshay23/gists{/gist_id}","starred_url":"https://api.github.com/users/akshay23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akshay23/subscriptions","organizations_url":"https://api.github.com/users/akshay23/orgs","repos_url":"https://api.github.com/users/akshay23/repos","events_url":"https://api.github.com/users/akshay23/events{/privacy}","received_events_url":"https://api.github.com/users/akshay23/received_events","type":"User","site_admin":false},"repo":{"id":27508770,"name":"SCloudRandomizer","full_name":"akshay23/SCloudRandomizer","owner":{"login":"akshay23","id":7291663,"avatar_url":"https://avatars.githubusercontent.com/u/7291663?v=3","gravatar_id":"","url":"https://api.github.com/users/akshay23","html_url":"https://github.com/akshay23","followers_url":"https://api.github.com/users/akshay23/followers","following_url":"https://api.github.com/users/akshay23/following{/other_user}","gists_url":"https://api.github.com/users/akshay23/gists{/gist_id}","starred_url":"https://api.github.com/users/akshay23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akshay23/subscriptions","organizations_url":"https://api.github.com/users/akshay23/orgs","repos_url":"https://api.github.com/users/akshay23/repos","events_url":"https://api.github.com/users/akshay23/events{/privacy}","received_events_url":"https://api.github.com/users/akshay23/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/akshay23/SCloudRandomizer","description":"iPhone app that plays a random song from SoundCloud","fork":false,"url":"https://api.github.com/repos/akshay23/SCloudRandomizer","forks_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/forks","keys_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/teams","hooks_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/hooks","issue_events_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues/events{/number}","events_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/events","assignees_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/assignees{/user}","branches_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/branches{/branch}","tags_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/tags","blobs_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/refs{/sha}","trees_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/statuses/{sha}","languages_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/languages","stargazers_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/stargazers","contributors_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/contributors","subscribers_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/subscribers","subscription_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/subscription","commits_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/commits{/sha}","git_commits_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/commits{/sha}","comments_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/comments{/number}","issue_comment_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues/comments{/number}","contents_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/contents/{+path}","compare_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/merges","archive_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/downloads","issues_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues{/number}","pulls_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls{/number}","milestones_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/milestones{/number}","notifications_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/labels{/name}","releases_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/releases{/id}","created_at":"2014-12-03T21:34:20Z","updated_at":"2015-05-04T17:07:01Z","pushed_at":"2015-05-26T14:18:29Z","git_url":"git://github.com/akshay23/SCloudRandomizer.git","ssh_url":"git@github.com:akshay23/SCloudRandomizer.git","clone_url":"https://github.com/akshay23/SCloudRandomizer.git","svn_url":"https://github.com/akshay23/SCloudRandomizer","homepage":null,"size":4832,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"akshay23:master","ref":"master","sha":"9af037d7e5a8c349d2391c8fcf2a6062b1c85456","user":{"login":"akshay23","id":7291663,"avatar_url":"https://avatars.githubusercontent.com/u/7291663?v=3","gravatar_id":"","url":"https://api.github.com/users/akshay23","html_url":"https://github.com/akshay23","followers_url":"https://api.github.com/users/akshay23/followers","following_url":"https://api.github.com/users/akshay23/following{/other_user}","gists_url":"https://api.github.com/users/akshay23/gists{/gist_id}","starred_url":"https://api.github.com/users/akshay23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akshay23/subscriptions","organizations_url":"https://api.github.com/users/akshay23/orgs","repos_url":"https://api.github.com/users/akshay23/repos","events_url":"https://api.github.com/users/akshay23/events{/privacy}","received_events_url":"https://api.github.com/users/akshay23/received_events","type":"User","site_admin":false},"repo":{"id":27508770,"name":"SCloudRandomizer","full_name":"akshay23/SCloudRandomizer","owner":{"login":"akshay23","id":7291663,"avatar_url":"https://avatars.githubusercontent.com/u/7291663?v=3","gravatar_id":"","url":"https://api.github.com/users/akshay23","html_url":"https://github.com/akshay23","followers_url":"https://api.github.com/users/akshay23/followers","following_url":"https://api.github.com/users/akshay23/following{/other_user}","gists_url":"https://api.github.com/users/akshay23/gists{/gist_id}","starred_url":"https://api.github.com/users/akshay23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akshay23/subscriptions","organizations_url":"https://api.github.com/users/akshay23/orgs","repos_url":"https://api.github.com/users/akshay23/repos","events_url":"https://api.github.com/users/akshay23/events{/privacy}","received_events_url":"https://api.github.com/users/akshay23/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/akshay23/SCloudRandomizer","description":"iPhone app that plays a random song from SoundCloud","fork":false,"url":"https://api.github.com/repos/akshay23/SCloudRandomizer","forks_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/forks","keys_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/teams","hooks_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/hooks","issue_events_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues/events{/number}","events_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/events","assignees_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/assignees{/user}","branches_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/branches{/branch}","tags_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/tags","blobs_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/refs{/sha}","trees_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/statuses/{sha}","languages_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/languages","stargazers_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/stargazers","contributors_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/contributors","subscribers_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/subscribers","subscription_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/subscription","commits_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/commits{/sha}","git_commits_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/git/commits{/sha}","comments_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/comments{/number}","issue_comment_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues/comments{/number}","contents_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/contents/{+path}","compare_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/merges","archive_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/downloads","issues_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues{/number}","pulls_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls{/number}","milestones_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/milestones{/number}","notifications_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/labels{/name}","releases_url":"https://api.github.com/repos/akshay23/SCloudRandomizer/releases{/id}","created_at":"2014-12-03T21:34:20Z","updated_at":"2015-05-04T17:07:01Z","pushed_at":"2015-05-26T14:18:29Z","git_url":"git://github.com/akshay23/SCloudRandomizer.git","ssh_url":"git@github.com:akshay23/SCloudRandomizer.git","clone_url":"https://github.com/akshay23/SCloudRandomizer.git","svn_url":"https://github.com/akshay23/SCloudRandomizer","homepage":null,"size":4832,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/15"},"html":{"href":"https://github.com/akshay23/SCloudRandomizer/pull/15"},"issue":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues/15"},"comments":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/akshay23/SCloudRandomizer/statuses/a84be667109ca0d65a4098ac99009bca5dd2d111"}}}}