{"action":"created","comment":{"url":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/comments/26826216","id":26826216,"diff_hunk":"@@ -1,43 +1,83 @@\n-import collections\n import json\n+from collections import Iterable\n+from datetime import datetime\n+\n+from requests import Request, Session\n \n-import requests\n import six\n \n \n-class YesGraphAPI(object):\n+def is_nonstring_iterable(obj):\n+    return isinstance(obj, Iterable) and not isinstance(obj, six.string_types)\n+\n+\n+def format_date(obj):\n+    if isinstance(obj, (int, six.string_types)):\n+        return obj\n+    elif isinstance(obj, datetime):\n+        return obj.isoformat()\n+    else:\n+        raise TypeError('Cannot format {0} as a date.'.format(obj))  # pragma: no cover\n+\n \n-    def __init__(self, secret_key, url='https://api.yesgraph.com/v0/'):\n+class YesGraphAPI(object):\n+    def __init__(self, secret_key, base_url='https://api.yesgraph.com/v0/'):\n         self.secret_key = secret_key\n-        self.base_url = url\n+        self.base_url = base_url\n+        self.session = Session()\n+\n+    def _build_url(self, endpoint):\n+        return '/'.join((self.base_url.rstrip('/'), endpoint.lstrip('/')))\n \n-        s = requests.Session()\n-        s.headers.update({\n+    def _prepare_request(self, method, endpoint, data=None):\n+        \"\"\"Builds and prepares the complete request, but does not send it.\"\"\"\n+        headers = {\n             'Authorization': 'Bearer {0}'.format(self.secret_key),\n-            'Content-Type': 'application/json',\n-        })\n-        self.session = s\n+        }\n+        if method != 'GET':","path":"yesgraph.py","position":47,"original_position":47,"commit_id":"f3a384bac40f51aacbde51f5cfeda68a71e3cd70","original_commit_id":"f3a384bac40f51aacbde51f5cfeda68a71e3cd70","user":{"login":"ghickman","id":31017,"avatar_url":"https://avatars.githubusercontent.com/u/31017?v=3","gravatar_id":"","url":"https://api.github.com/users/ghickman","html_url":"https://github.com/ghickman","followers_url":"https://api.github.com/users/ghickman/followers","following_url":"https://api.github.com/users/ghickman/following{/other_user}","gists_url":"https://api.github.com/users/ghickman/gists{/gist_id}","starred_url":"https://api.github.com/users/ghickman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghickman/subscriptions","organizations_url":"https://api.github.com/users/ghickman/orgs","repos_url":"https://api.github.com/users/ghickman/repos","events_url":"https://api.github.com/users/ghickman/events{/privacy}","received_events_url":"https://api.github.com/users/ghickman/received_events","type":"User","site_admin":false},"body":"Seems like we could ignore this check and set the content-type on GETs too? Purely for simplicity.","created_at":"2015-03-20T09:08:06Z","updated_at":"2015-03-20T09:08:06Z","html_url":"https://github.com/YesGraph/python-yesgraph/pull/3#discussion_r26826216","pull_request_url":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/comments/26826216"},"html":{"href":"https://github.com/YesGraph/python-yesgraph/pull/3#discussion_r26826216"},"pull_request":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/3","id":31578511,"html_url":"https://github.com/YesGraph/python-yesgraph/pull/3","diff_url":"https://github.com/YesGraph/python-yesgraph/pull/3.diff","patch_url":"https://github.com/YesGraph/python-yesgraph/pull/3.patch","issue_url":"https://api.github.com/repos/YesGraph/python-yesgraph/issues/3","number":3,"state":"open","locked":false,"title":"Add/fix tests","user":{"login":"nvie","id":83844,"avatar_url":"https://avatars.githubusercontent.com/u/83844?v=3","gravatar_id":"","url":"https://api.github.com/users/nvie","html_url":"https://github.com/nvie","followers_url":"https://api.github.com/users/nvie/followers","following_url":"https://api.github.com/users/nvie/following{/other_user}","gists_url":"https://api.github.com/users/nvie/gists{/gist_id}","starred_url":"https://api.github.com/users/nvie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvie/subscriptions","organizations_url":"https://api.github.com/users/nvie/orgs","repos_url":"https://api.github.com/users/nvie/repos","events_url":"https://api.github.com/users/nvie/events{/privacy}","received_events_url":"https://api.github.com/users/nvie/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n\r\nAdds tests for all endpoints, making sure we're preparing our requests in the correct fashion. I've made some minor changes to the client along the way (renaming arguments, making some optional, etc.)\r\n\r\n#### How should this be manually tested?\r\n\r\nSimply run `tox`. It should not make any actual HTTP requests, so the API service does not have to be running for this to work.","created_at":"2015-03-20T00:11:19Z","updated_at":"2015-03-20T09:08:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"04fabb60f186014a86a26d822bb4712375eb63be","assignee":{"login":"ghickman","id":31017,"avatar_url":"https://avatars.githubusercontent.com/u/31017?v=3","gravatar_id":"","url":"https://api.github.com/users/ghickman","html_url":"https://github.com/ghickman","followers_url":"https://api.github.com/users/ghickman/followers","following_url":"https://api.github.com/users/ghickman/following{/other_user}","gists_url":"https://api.github.com/users/ghickman/gists{/gist_id}","starred_url":"https://api.github.com/users/ghickman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghickman/subscriptions","organizations_url":"https://api.github.com/users/ghickman/orgs","repos_url":"https://api.github.com/users/ghickman/repos","events_url":"https://api.github.com/users/ghickman/events{/privacy}","received_events_url":"https://api.github.com/users/ghickman/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/3/commits","review_comments_url":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/3/comments","review_comment_url":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/YesGraph/python-yesgraph/issues/3/comments","statuses_url":"https://api.github.com/repos/YesGraph/python-yesgraph/statuses/f3a384bac40f51aacbde51f5cfeda68a71e3cd70","head":{"label":"YesGraph:add-tests","ref":"add-tests","sha":"f3a384bac40f51aacbde51f5cfeda68a71e3cd70","user":{"login":"YesGraph","id":4250361,"avatar_url":"https://avatars.githubusercontent.com/u/4250361?v=3","gravatar_id":"","url":"https://api.github.com/users/YesGraph","html_url":"https://github.com/YesGraph","followers_url":"https://api.github.com/users/YesGraph/followers","following_url":"https://api.github.com/users/YesGraph/following{/other_user}","gists_url":"https://api.github.com/users/YesGraph/gists{/gist_id}","starred_url":"https://api.github.com/users/YesGraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YesGraph/subscriptions","organizations_url":"https://api.github.com/users/YesGraph/orgs","repos_url":"https://api.github.com/users/YesGraph/repos","events_url":"https://api.github.com/users/YesGraph/events{/privacy}","received_events_url":"https://api.github.com/users/YesGraph/received_events","type":"Organization","site_admin":false},"repo":{"id":31993089,"name":"python-yesgraph","full_name":"YesGraph/python-yesgraph","owner":{"login":"YesGraph","id":4250361,"avatar_url":"https://avatars.githubusercontent.com/u/4250361?v=3","gravatar_id":"","url":"https://api.github.com/users/YesGraph","html_url":"https://github.com/YesGraph","followers_url":"https://api.github.com/users/YesGraph/followers","following_url":"https://api.github.com/users/YesGraph/following{/other_user}","gists_url":"https://api.github.com/users/YesGraph/gists{/gist_id}","starred_url":"https://api.github.com/users/YesGraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YesGraph/subscriptions","organizations_url":"https://api.github.com/users/YesGraph/orgs","repos_url":"https://api.github.com/users/YesGraph/repos","events_url":"https://api.github.com/users/YesGraph/events{/privacy}","received_events_url":"https://api.github.com/users/YesGraph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/YesGraph/python-yesgraph","description":"Python wrapper for the YesGraph API","fork":false,"url":"https://api.github.com/repos/YesGraph/python-yesgraph","forks_url":"https://api.github.com/repos/YesGraph/python-yesgraph/forks","keys_url":"https://api.github.com/repos/YesGraph/python-yesgraph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/YesGraph/python-yesgraph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/YesGraph/python-yesgraph/teams","hooks_url":"https://api.github.com/repos/YesGraph/python-yesgraph/hooks","issue_events_url":"https://api.github.com/repos/YesGraph/python-yesgraph/issues/events{/number}","events_url":"https://api.github.com/repos/YesGraph/python-yesgraph/events","assignees_url":"https://api.github.com/repos/YesGraph/python-yesgraph/assignees{/user}","branches_url":"https://api.github.com/repos/YesGraph/python-yesgraph/branches{/branch}","tags_url":"https://api.github.com/repos/YesGraph/python-yesgraph/tags","blobs_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/refs{/sha}","trees_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/YesGraph/python-yesgraph/statuses/{sha}","languages_url":"https://api.github.com/repos/YesGraph/python-yesgraph/languages","stargazers_url":"https://api.github.com/repos/YesGraph/python-yesgraph/stargazers","contributors_url":"https://api.github.com/repos/YesGraph/python-yesgraph/contributors","subscribers_url":"https://api.github.com/repos/YesGraph/python-yesgraph/subscribers","subscription_url":"https://api.github.com/repos/YesGraph/python-yesgraph/subscription","commits_url":"https://api.github.com/repos/YesGraph/python-yesgraph/commits{/sha}","git_commits_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/commits{/sha}","comments_url":"https://api.github.com/repos/YesGraph/python-yesgraph/comments{/number}","issue_comment_url":"https://api.github.com/repos/YesGraph/python-yesgraph/issues/comments{/number}","contents_url":"https://api.github.com/repos/YesGraph/python-yesgraph/contents/{+path}","compare_url":"https://api.github.com/repos/YesGraph/python-yesgraph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/YesGraph/python-yesgraph/merges","archive_url":"https://api.github.com/repos/YesGraph/python-yesgraph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/YesGraph/python-yesgraph/downloads","issues_url":"https://api.github.com/repos/YesGraph/python-yesgraph/issues{/number}","pulls_url":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls{/number}","milestones_url":"https://api.github.com/repos/YesGraph/python-yesgraph/milestones{/number}","notifications_url":"https://api.github.com/repos/YesGraph/python-yesgraph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/YesGraph/python-yesgraph/labels{/name}","releases_url":"https://api.github.com/repos/YesGraph/python-yesgraph/releases{/id}","created_at":"2015-03-11T02:07:25Z","updated_at":"2015-03-20T08:28:26Z","pushed_at":"2015-03-20T08:28:26Z","git_url":"git://github.com/YesGraph/python-yesgraph.git","ssh_url":"git@github.com:YesGraph/python-yesgraph.git","clone_url":"https://github.com/YesGraph/python-yesgraph.git","svn_url":"https://github.com/YesGraph/python-yesgraph","homepage":null,"size":187,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"YesGraph:master","ref":"master","sha":"62372687f11e31cd54c72aa835bc1f410176bb87","user":{"login":"YesGraph","id":4250361,"avatar_url":"https://avatars.githubusercontent.com/u/4250361?v=3","gravatar_id":"","url":"https://api.github.com/users/YesGraph","html_url":"https://github.com/YesGraph","followers_url":"https://api.github.com/users/YesGraph/followers","following_url":"https://api.github.com/users/YesGraph/following{/other_user}","gists_url":"https://api.github.com/users/YesGraph/gists{/gist_id}","starred_url":"https://api.github.com/users/YesGraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YesGraph/subscriptions","organizations_url":"https://api.github.com/users/YesGraph/orgs","repos_url":"https://api.github.com/users/YesGraph/repos","events_url":"https://api.github.com/users/YesGraph/events{/privacy}","received_events_url":"https://api.github.com/users/YesGraph/received_events","type":"Organization","site_admin":false},"repo":{"id":31993089,"name":"python-yesgraph","full_name":"YesGraph/python-yesgraph","owner":{"login":"YesGraph","id":4250361,"avatar_url":"https://avatars.githubusercontent.com/u/4250361?v=3","gravatar_id":"","url":"https://api.github.com/users/YesGraph","html_url":"https://github.com/YesGraph","followers_url":"https://api.github.com/users/YesGraph/followers","following_url":"https://api.github.com/users/YesGraph/following{/other_user}","gists_url":"https://api.github.com/users/YesGraph/gists{/gist_id}","starred_url":"https://api.github.com/users/YesGraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YesGraph/subscriptions","organizations_url":"https://api.github.com/users/YesGraph/orgs","repos_url":"https://api.github.com/users/YesGraph/repos","events_url":"https://api.github.com/users/YesGraph/events{/privacy}","received_events_url":"https://api.github.com/users/YesGraph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/YesGraph/python-yesgraph","description":"Python wrapper for the YesGraph API","fork":false,"url":"https://api.github.com/repos/YesGraph/python-yesgraph","forks_url":"https://api.github.com/repos/YesGraph/python-yesgraph/forks","keys_url":"https://api.github.com/repos/YesGraph/python-yesgraph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/YesGraph/python-yesgraph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/YesGraph/python-yesgraph/teams","hooks_url":"https://api.github.com/repos/YesGraph/python-yesgraph/hooks","issue_events_url":"https://api.github.com/repos/YesGraph/python-yesgraph/issues/events{/number}","events_url":"https://api.github.com/repos/YesGraph/python-yesgraph/events","assignees_url":"https://api.github.com/repos/YesGraph/python-yesgraph/assignees{/user}","branches_url":"https://api.github.com/repos/YesGraph/python-yesgraph/branches{/branch}","tags_url":"https://api.github.com/repos/YesGraph/python-yesgraph/tags","blobs_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/refs{/sha}","trees_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/YesGraph/python-yesgraph/statuses/{sha}","languages_url":"https://api.github.com/repos/YesGraph/python-yesgraph/languages","stargazers_url":"https://api.github.com/repos/YesGraph/python-yesgraph/stargazers","contributors_url":"https://api.github.com/repos/YesGraph/python-yesgraph/contributors","subscribers_url":"https://api.github.com/repos/YesGraph/python-yesgraph/subscribers","subscription_url":"https://api.github.com/repos/YesGraph/python-yesgraph/subscription","commits_url":"https://api.github.com/repos/YesGraph/python-yesgraph/commits{/sha}","git_commits_url":"https://api.github.com/repos/YesGraph/python-yesgraph/git/commits{/sha}","comments_url":"https://api.github.com/repos/YesGraph/python-yesgraph/comments{/number}","issue_comment_url":"https://api.github.com/repos/YesGraph/python-yesgraph/issues/comments{/number}","contents_url":"https://api.github.com/repos/YesGraph/python-yesgraph/contents/{+path}","compare_url":"https://api.github.com/repos/YesGraph/python-yesgraph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/YesGraph/python-yesgraph/merges","archive_url":"https://api.github.com/repos/YesGraph/python-yesgraph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/YesGraph/python-yesgraph/downloads","issues_url":"https://api.github.com/repos/YesGraph/python-yesgraph/issues{/number}","pulls_url":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls{/number}","milestones_url":"https://api.github.com/repos/YesGraph/python-yesgraph/milestones{/number}","notifications_url":"https://api.github.com/repos/YesGraph/python-yesgraph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/YesGraph/python-yesgraph/labels{/name}","releases_url":"https://api.github.com/repos/YesGraph/python-yesgraph/releases{/id}","created_at":"2015-03-11T02:07:25Z","updated_at":"2015-03-20T08:28:26Z","pushed_at":"2015-03-20T08:28:26Z","git_url":"git://github.com/YesGraph/python-yesgraph.git","ssh_url":"git@github.com:YesGraph/python-yesgraph.git","clone_url":"https://github.com/YesGraph/python-yesgraph.git","svn_url":"https://github.com/YesGraph/python-yesgraph","homepage":null,"size":187,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/3"},"html":{"href":"https://github.com/YesGraph/python-yesgraph/pull/3"},"issue":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/issues/3"},"comments":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/YesGraph/python-yesgraph/statuses/f3a384bac40f51aacbde51f5cfeda68a71e3cd70"}}}}