{"action":"created","comment":{"url":"https://api.github.com/repos/pinax/pinax-ratings/pulls/comments/168850691","pull_request_review_id":97292570,"id":168850691,"diff_hunk":"@@ -0,0 +1,221 @@\n+from django.contrib.contenttypes.models import ContentType\n+from django.template import Context, Template\n+\n+from .models import Car\n+from .test import TestCase\n+\n+\n+class TemplateTagsTest(TestCase):\n+    \"\"\"\n+    Tests for the template tags\n+    \"\"\"\n+\n+    def setUp(self):\n+        self.test_user = self.make_user(username=\"test_user\")\n+        self.another_user = self.make_user(username=\"another_user\")\n+        self.none_car_object = self.make_user(username=\"a_user\")\n+        self.benz = Car.objects.create(name=\"Mercedes c200\")\n+        self.post_a_rating(self.test_user, 2)\n+\n+    def post_a_rating(self, user, rating):\n+        \"\"\"\n+        Helper function to post a rating for the benz object of\n+        type Car used in the tests\n+        :param user: User\n+        :param rating: int\n+        :return: http response object\n+        \"\"\"\n+        with self.login(user):\n+            return self.post(\n+                \"pinax_ratings:rate\",\n+                content_type_id=ContentType.objects.get_for_model(self.benz).pk,\n+                object_id=self.benz.pk,\n+                data={\n+                    \"rating\": rating,\n+                    \"category\": \"handling\"\n+                },\n+            )\n+\n+    def test_user_rating_tag_with_category(self):\n+        \"\"\"\n+        Ensure the template tag user_rating renders a rating\n+        as posted by the user on a Car object they are rating\n+        for a specified category in the context\n+        \"\"\"\n+\n+        template = Template(\n+            \"{% load pinax_ratings_tags %}\"\n+            \"{% user_rating user object category as the_rating %}\"\n+        )\n+        context = Context({\n+            \"user\": self.test_user,\n+            \"object\": self.benz,\n+            \"category\": \"handling\"\n+        })\n+        template.render(context)\n+        self.assertEqual(context[\"the_rating\"], 2)\n+\n+    def test_user_rating_tag_no_category(self):\n+        \"\"\"\n+        Ensure the template tag user_rating renders a rating\n+        as posted by the user on a Car object they are rating.\n+        in this test, no category is specified\n+        \"\"\"\n+\n+        template = Template(\n+            \"{% load pinax_ratings_tags %}\"\n+            \"{% user_rating user object category as the_rating %}\"\n+        )\n+        context = Context({\n+            \"user\": self.test_user,\n+            \"object\": self.benz,\n+            \"category\": \"\"\n+        })\n+        template.render(context)\n+        self.assertEqual(context[\"the_rating\"], 2)\n+\n+    def test_overall_rating_tag_with_category(self):\n+        \"\"\"\n+        Ensure the template tag overall_rating renders an\n+        overall rating for a specified category in the\n+        context\n+        \"\"\"\n+\n+        self.post_a_rating(self.another_user, 3)\n+\n+        template = Template(\n+            \"{% load pinax_ratings_tags %}\"\n+            \"{% overall_rating object category as the_overall_rating %}\"\n+        )\n+        context = Context({\n+            \"object\": self.benz,\n+            \"category\": \"handling\"\n+        })\n+        template.render(context)\n+        self.assertEqual(context[\"the_overall_rating\"], 2.5)\n+\n+    def test_overall_rating_tag_with_no_category(self):\n+        \"\"\"\n+        Ensure the template tag overall_rating renders an\n+        overall rating. in this test, no category is specified\n+        \"\"\"\n+\n+        template = Template(\n+            \"{% load pinax_ratings_tags %}\"\n+            \"{% overall_rating object category as the_overall_rating %}\"\n+        )\n+        context = Context({\n+            \"object\": self.benz,\n+            \"category\": \"\"\n+        })\n+        template.render(context)\n+        self.assertEqual(context[\"the_overall_rating\"], 2.0)","path":"pinax/ratings/tests/test_tags.py","position":112,"original_position":112,"commit_id":"4370a36f35546f64931495dbc694a21961f45d50","original_commit_id":"4370a36f35546f64931495dbc694a21961f45d50","user":{"login":"kasulani","id":6205925,"avatar_url":"https://avatars1.githubusercontent.com/u/6205925?v=4","gravatar_id":"","url":"https://api.github.com/users/kasulani","html_url":"https://github.com/kasulani","followers_url":"https://api.github.com/users/kasulani/followers","following_url":"https://api.github.com/users/kasulani/following{/other_user}","gists_url":"https://api.github.com/users/kasulani/gists{/gist_id}","starred_url":"https://api.github.com/users/kasulani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasulani/subscriptions","organizations_url":"https://api.github.com/users/kasulani/orgs","repos_url":"https://api.github.com/users/kasulani/repos","events_url":"https://api.github.com/users/kasulani/events{/privacy}","received_events_url":"https://api.github.com/users/kasulani/received_events","type":"User","site_admin":false},"body":"Done @grahamu as requested","created_at":"2018-02-16T19:34:17Z","updated_at":"2018-02-16T19:34:17Z","html_url":"https://github.com/pinax/pinax-ratings/pull/47#discussion_r168850691","pull_request_url":"https://api.github.com/repos/pinax/pinax-ratings/pulls/47","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/pinax/pinax-ratings/pulls/comments/168850691"},"html":{"href":"https://github.com/pinax/pinax-ratings/pull/47#discussion_r168850691"},"pull_request":{"href":"https://api.github.com/repos/pinax/pinax-ratings/pulls/47"}},"in_reply_to_id":167414090},"pull_request":{"url":"https://api.github.com/repos/pinax/pinax-ratings/pulls/47","id":168331500,"html_url":"https://github.com/pinax/pinax-ratings/pull/47","diff_url":"https://github.com/pinax/pinax-ratings/pull/47.diff","patch_url":"https://github.com/pinax/pinax-ratings/pull/47.patch","issue_url":"https://api.github.com/repos/pinax/pinax-ratings/issues/47","number":47,"state":"open","locked":false,"title":"Add Template tag tests","user":{"login":"kasulani","id":6205925,"avatar_url":"https://avatars1.githubusercontent.com/u/6205925?v=4","gravatar_id":"","url":"https://api.github.com/users/kasulani","html_url":"https://github.com/kasulani","followers_url":"https://api.github.com/users/kasulani/followers","following_url":"https://api.github.com/users/kasulani/following{/other_user}","gists_url":"https://api.github.com/users/kasulani/gists{/gist_id}","starred_url":"https://api.github.com/users/kasulani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasulani/subscriptions","organizations_url":"https://api.github.com/users/kasulani/orgs","repos_url":"https://api.github.com/users/kasulani/repos","events_url":"https://api.github.com/users/kasulani/events{/privacy}","received_events_url":"https://api.github.com/users/kasulani/received_events","type":"User","site_admin":false},"body":"* Add tests for template tags\r\n* Fixes #44 ","created_at":"2018-02-09T20:10:07Z","updated_at":"2018-02-16T19:34:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96433e5c2a8c974b291686e2c4652cf41af9ec6d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pinax/pinax-ratings/pulls/47/commits","review_comments_url":"https://api.github.com/repos/pinax/pinax-ratings/pulls/47/comments","review_comment_url":"https://api.github.com/repos/pinax/pinax-ratings/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pinax/pinax-ratings/issues/47/comments","statuses_url":"https://api.github.com/repos/pinax/pinax-ratings/statuses/4370a36f35546f64931495dbc694a21961f45d50","head":{"label":"kasulani:template-tag-tests","ref":"template-tag-tests","sha":"4370a36f35546f64931495dbc694a21961f45d50","user":{"login":"kasulani","id":6205925,"avatar_url":"https://avatars1.githubusercontent.com/u/6205925?v=4","gravatar_id":"","url":"https://api.github.com/users/kasulani","html_url":"https://github.com/kasulani","followers_url":"https://api.github.com/users/kasulani/followers","following_url":"https://api.github.com/users/kasulani/following{/other_user}","gists_url":"https://api.github.com/users/kasulani/gists{/gist_id}","starred_url":"https://api.github.com/users/kasulani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasulani/subscriptions","organizations_url":"https://api.github.com/users/kasulani/orgs","repos_url":"https://api.github.com/users/kasulani/repos","events_url":"https://api.github.com/users/kasulani/events{/privacy}","received_events_url":"https://api.github.com/users/kasulani/received_events","type":"User","site_admin":false},"repo":{"id":119501171,"name":"pinax-ratings","full_name":"kasulani/pinax-ratings","owner":{"login":"kasulani","id":6205925,"avatar_url":"https://avatars1.githubusercontent.com/u/6205925?v=4","gravatar_id":"","url":"https://api.github.com/users/kasulani","html_url":"https://github.com/kasulani","followers_url":"https://api.github.com/users/kasulani/followers","following_url":"https://api.github.com/users/kasulani/following{/other_user}","gists_url":"https://api.github.com/users/kasulani/gists{/gist_id}","starred_url":"https://api.github.com/users/kasulani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasulani/subscriptions","organizations_url":"https://api.github.com/users/kasulani/orgs","repos_url":"https://api.github.com/users/kasulani/repos","events_url":"https://api.github.com/users/kasulani/events{/privacy}","received_events_url":"https://api.github.com/users/kasulani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kasulani/pinax-ratings","description":"a ratings app for Django","fork":true,"url":"https://api.github.com/repos/kasulani/pinax-ratings","forks_url":"https://api.github.com/repos/kasulani/pinax-ratings/forks","keys_url":"https://api.github.com/repos/kasulani/pinax-ratings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kasulani/pinax-ratings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kasulani/pinax-ratings/teams","hooks_url":"https://api.github.com/repos/kasulani/pinax-ratings/hooks","issue_events_url":"https://api.github.com/repos/kasulani/pinax-ratings/issues/events{/number}","events_url":"https://api.github.com/repos/kasulani/pinax-ratings/events","assignees_url":"https://api.github.com/repos/kasulani/pinax-ratings/assignees{/user}","branches_url":"https://api.github.com/repos/kasulani/pinax-ratings/branches{/branch}","tags_url":"https://api.github.com/repos/kasulani/pinax-ratings/tags","blobs_url":"https://api.github.com/repos/kasulani/pinax-ratings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kasulani/pinax-ratings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kasulani/pinax-ratings/git/refs{/sha}","trees_url":"https://api.github.com/repos/kasulani/pinax-ratings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kasulani/pinax-ratings/statuses/{sha}","languages_url":"https://api.github.com/repos/kasulani/pinax-ratings/languages","stargazers_url":"https://api.github.com/repos/kasulani/pinax-ratings/stargazers","contributors_url":"https://api.github.com/repos/kasulani/pinax-ratings/contributors","subscribers_url":"https://api.github.com/repos/kasulani/pinax-ratings/subscribers","subscription_url":"https://api.github.com/repos/kasulani/pinax-ratings/subscription","commits_url":"https://api.github.com/repos/kasulani/pinax-ratings/commits{/sha}","git_commits_url":"https://api.github.com/repos/kasulani/pinax-ratings/git/commits{/sha}","comments_url":"https://api.github.com/repos/kasulani/pinax-ratings/comments{/number}","issue_comment_url":"https://api.github.com/repos/kasulani/pinax-ratings/issues/comments{/number}","contents_url":"https://api.github.com/repos/kasulani/pinax-ratings/contents/{+path}","compare_url":"https://api.github.com/repos/kasulani/pinax-ratings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kasulani/pinax-ratings/merges","archive_url":"https://api.github.com/repos/kasulani/pinax-ratings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kasulani/pinax-ratings/downloads","issues_url":"https://api.github.com/repos/kasulani/pinax-ratings/issues{/number}","pulls_url":"https://api.github.com/repos/kasulani/pinax-ratings/pulls{/number}","milestones_url":"https://api.github.com/repos/kasulani/pinax-ratings/milestones{/number}","notifications_url":"https://api.github.com/repos/kasulani/pinax-ratings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kasulani/pinax-ratings/labels{/name}","releases_url":"https://api.github.com/repos/kasulani/pinax-ratings/releases{/id}","deployments_url":"https://api.github.com/repos/kasulani/pinax-ratings/deployments","created_at":"2018-01-30T07:47:39Z","updated_at":"2018-01-30T07:47:40Z","pushed_at":"2018-02-09T20:07:41Z","git_url":"git://github.com/kasulani/pinax-ratings.git","ssh_url":"git@github.com:kasulani/pinax-ratings.git","clone_url":"https://github.com/kasulani/pinax-ratings.git","svn_url":"https://github.com/kasulani/pinax-ratings","homepage":"","size":153,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pinax:master","ref":"master","sha":"5d31aa9ee120a917119e6f02939af321883af758","user":{"login":"pinax","id":26053,"avatar_url":"https://avatars0.githubusercontent.com/u/26053?v=4","gravatar_id":"","url":"https://api.github.com/users/pinax","html_url":"https://github.com/pinax","followers_url":"https://api.github.com/users/pinax/followers","following_url":"https://api.github.com/users/pinax/following{/other_user}","gists_url":"https://api.github.com/users/pinax/gists{/gist_id}","starred_url":"https://api.github.com/users/pinax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pinax/subscriptions","organizations_url":"https://api.github.com/users/pinax/orgs","repos_url":"https://api.github.com/users/pinax/repos","events_url":"https://api.github.com/users/pinax/events{/privacy}","received_events_url":"https://api.github.com/users/pinax/received_events","type":"Organization","site_admin":false},"repo":{"id":2608812,"name":"pinax-ratings","full_name":"pinax/pinax-ratings","owner":{"login":"pinax","id":26053,"avatar_url":"https://avatars0.githubusercontent.com/u/26053?v=4","gravatar_id":"","url":"https://api.github.com/users/pinax","html_url":"https://github.com/pinax","followers_url":"https://api.github.com/users/pinax/followers","following_url":"https://api.github.com/users/pinax/following{/other_user}","gists_url":"https://api.github.com/users/pinax/gists{/gist_id}","starred_url":"https://api.github.com/users/pinax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pinax/subscriptions","organizations_url":"https://api.github.com/users/pinax/orgs","repos_url":"https://api.github.com/users/pinax/repos","events_url":"https://api.github.com/users/pinax/events{/privacy}","received_events_url":"https://api.github.com/users/pinax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pinax/pinax-ratings","description":"a ratings app for Django","fork":false,"url":"https://api.github.com/repos/pinax/pinax-ratings","forks_url":"https://api.github.com/repos/pinax/pinax-ratings/forks","keys_url":"https://api.github.com/repos/pinax/pinax-ratings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pinax/pinax-ratings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pinax/pinax-ratings/teams","hooks_url":"https://api.github.com/repos/pinax/pinax-ratings/hooks","issue_events_url":"https://api.github.com/repos/pinax/pinax-ratings/issues/events{/number}","events_url":"https://api.github.com/repos/pinax/pinax-ratings/events","assignees_url":"https://api.github.com/repos/pinax/pinax-ratings/assignees{/user}","branches_url":"https://api.github.com/repos/pinax/pinax-ratings/branches{/branch}","tags_url":"https://api.github.com/repos/pinax/pinax-ratings/tags","blobs_url":"https://api.github.com/repos/pinax/pinax-ratings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pinax/pinax-ratings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pinax/pinax-ratings/git/refs{/sha}","trees_url":"https://api.github.com/repos/pinax/pinax-ratings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pinax/pinax-ratings/statuses/{sha}","languages_url":"https://api.github.com/repos/pinax/pinax-ratings/languages","stargazers_url":"https://api.github.com/repos/pinax/pinax-ratings/stargazers","contributors_url":"https://api.github.com/repos/pinax/pinax-ratings/contributors","subscribers_url":"https://api.github.com/repos/pinax/pinax-ratings/subscribers","subscription_url":"https://api.github.com/repos/pinax/pinax-ratings/subscription","commits_url":"https://api.github.com/repos/pinax/pinax-ratings/commits{/sha}","git_commits_url":"https://api.github.com/repos/pinax/pinax-ratings/git/commits{/sha}","comments_url":"https://api.github.com/repos/pinax/pinax-ratings/comments{/number}","issue_comment_url":"https://api.github.com/repos/pinax/pinax-ratings/issues/comments{/number}","contents_url":"https://api.github.com/repos/pinax/pinax-ratings/contents/{+path}","compare_url":"https://api.github.com/repos/pinax/pinax-ratings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pinax/pinax-ratings/merges","archive_url":"https://api.github.com/repos/pinax/pinax-ratings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pinax/pinax-ratings/downloads","issues_url":"https://api.github.com/repos/pinax/pinax-ratings/issues{/number}","pulls_url":"https://api.github.com/repos/pinax/pinax-ratings/pulls{/number}","milestones_url":"https://api.github.com/repos/pinax/pinax-ratings/milestones{/number}","notifications_url":"https://api.github.com/repos/pinax/pinax-ratings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pinax/pinax-ratings/labels{/name}","releases_url":"https://api.github.com/repos/pinax/pinax-ratings/releases{/id}","deployments_url":"https://api.github.com/repos/pinax/pinax-ratings/deployments","created_at":"2011-10-19T20:23:26Z","updated_at":"2017-10-15T11:52:43Z","pushed_at":"2018-02-09T20:10:08Z","git_url":"git://github.com/pinax/pinax-ratings.git","ssh_url":"git@github.com:pinax/pinax-ratings.git","clone_url":"https://github.com/pinax/pinax-ratings.git","svn_url":"https://github.com/pinax/pinax-ratings","homepage":"","size":150,"stargazers_count":59,"watchers_count":59,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":25,"open_issues":12,"watchers":59,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pinax/pinax-ratings/pulls/47"},"html":{"href":"https://github.com/pinax/pinax-ratings/pull/47"},"issue":{"href":"https://api.github.com/repos/pinax/pinax-ratings/issues/47"},"comments":{"href":"https://api.github.com/repos/pinax/pinax-ratings/issues/47/comments"},"review_comments":{"href":"https://api.github.com/repos/pinax/pinax-ratings/pulls/47/comments"},"review_comment":{"href":"https://api.github.com/repos/pinax/pinax-ratings/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pinax/pinax-ratings/pulls/47/commits"},"statuses":{"href":"https://api.github.com/repos/pinax/pinax-ratings/statuses/4370a36f35546f64931495dbc694a21961f45d50"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kasulani"}}