{"action":"created","comment":{"url":"https://api.github.com/repos/google/ggrc-core/pulls/comments/58531578","id":58531578,"diff_hunk":"@@ -0,0 +1,77 @@\n+# Copyright (C) 2016 Google Inc., authors, and contributors <see AUTHORS file>\n+# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n+# Created By: miha@reciprocitylabs.com\n+# Maintained By: miha@reciprocitylabs.com\n+\n+\"\"\"Tests for notifications for models with assignable mixin.\"\"\"\n+\n+from sqlalchemy import and_\n+\n+from ggrc import db\n+from ggrc.notifications import data_handlers\n+from ggrc.models import Request\n+from ggrc.models import Notification\n+from ggrc.models import NotificationType\n+from integration.ggrc import converters\n+from integration.ggrc import api_helper\n+\n+\n+class TestRequestDataHandlers(converters.TestCase):\n+  \"\"\"Test data handlers for various request notifications.\"\"\"\n+\n+  def setUp(self):\n+    converters.TestCase.setUp(self)\n+    self.client.get(\"/login\")\n+    self.api_helper = api_helper.Api()\n+    self.import_file(\"request_full_no_warnings.csv\")\n+    self.request1 = Request.query.filter_by(slug=\"Request 1\").one()\n+    self.request3 = Request.query.filter_by(slug=\"Request 3\").one()\n+\n+  def _get_notification(self, obj, notif_type):\n+    return db.session.query(Notification).join(NotificationType).filter(and_(\n+        Notification.object_id == obj.id,\n+        Notification.object_type == obj.type,\n+        NotificationType.name == notif_type,\n+    ))\n+\n+  def test_open_request(self):\n+    \"\"\"Test data handlers for opened requests.\"\"\"\n+    notif = self._get_notification(self.request1, \"request_open\").first()\n+    open_data = data_handlers.get_request_data(notif)\n+    request_1_expected_keys = set([\n+        \"user1@a.com\",\n+        \"user2@a.com\",\n+        \"user3@a.com\",\n+        \"user4@a.com\",\n+        \"user5@a.com\",\n+    ])\n+\n+    self.assertEqual(set(open_data.keys()), request_1_expected_keys)\n+\n+    notif = self._get_notification(self.request3, \"request_open\").first()\n+    open_data = data_handlers.get_request_data(notif)\n+    request_3_expected_keys = set([\n+        \"user1@a.com\",\n+        \"user2@a.com\",\n+        \"user@example.com\",\n+    ])\n+\n+    self.assertEqual(set(open_data.keys()), request_3_expected_keys)\n+\n+  def test_declined_request(self):\n+    \"\"\"Test data handlers for declined requests\"\"\"\n+\n+    # decline request 1\n+    self.api_helper.modify_object(self.request1, {\"status\": \"Finished\"})\n+    self.api_helper.modify_object(self.request1, {\"status\": \"In Progress\"})\n+\n+    notif = self._get_notification(self.request1, \"request_declined\").first()\n+    declined_data = data_handlers.get_request_data(notif)\n+    requester_emails = set([\n+        \"user2@a.com\",\n+        \"user3@a.com\",\n+    ])\n+\n+    self.assertEqual(set(declined_data.keys()), requester_emails)\n+\n+    print declined_data","path":"test/integration/ggrc/notifications/test_data_handlers.py","position":77,"original_position":77,"commit_id":"76e2055dab82c3af03ac03e30a537900d140c306","original_commit_id":"b651dde54681de1becf91146d6ab958dd4bae9a7","user":{"login":"uskudnik","id":120451,"avatar_url":"https://avatars.githubusercontent.com/u/120451?v=3","gravatar_id":"","url":"https://api.github.com/users/uskudnik","html_url":"https://github.com/uskudnik","followers_url":"https://api.github.com/users/uskudnik/followers","following_url":"https://api.github.com/users/uskudnik/following{/other_user}","gists_url":"https://api.github.com/users/uskudnik/gists{/gist_id}","starred_url":"https://api.github.com/users/uskudnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uskudnik/subscriptions","organizations_url":"https://api.github.com/users/uskudnik/orgs","repos_url":"https://api.github.com/users/uskudnik/repos","events_url":"https://api.github.com/users/uskudnik/events{/privacy}","received_events_url":"https://api.github.com/users/uskudnik/received_events","type":"User","site_admin":false},"body":"Forgotten print","created_at":"2016-04-05T12:50:30Z","updated_at":"2016-04-05T12:50:30Z","html_url":"https://github.com/google/ggrc-core/pull/3662#discussion_r58531578","pull_request_url":"https://api.github.com/repos/google/ggrc-core/pulls/3662","_links":{"self":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/comments/58531578"},"html":{"href":"https://github.com/google/ggrc-core/pull/3662#discussion_r58531578"},"pull_request":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/3662"}}},"pull_request":{"url":"https://api.github.com/repos/google/ggrc-core/pulls/3662","id":62771639,"html_url":"https://github.com/google/ggrc-core/pull/3662","diff_url":"https://github.com/google/ggrc-core/pull/3662.diff","patch_url":"https://github.com/google/ggrc-core/pull/3662.patch","issue_url":"https://api.github.com/repos/google/ggrc-core/issues/3662","number":3662,"state":"open","locked":false,"title":"CORE-2377 Add notifications for assignable mixin","user":{"login":"zidarsk8","id":566311,"avatar_url":"https://avatars.githubusercontent.com/u/566311?v=3","gravatar_id":"","url":"https://api.github.com/users/zidarsk8","html_url":"https://github.com/zidarsk8","followers_url":"https://api.github.com/users/zidarsk8/followers","following_url":"https://api.github.com/users/zidarsk8/following{/other_user}","gists_url":"https://api.github.com/users/zidarsk8/gists{/gist_id}","starred_url":"https://api.github.com/users/zidarsk8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zidarsk8/subscriptions","organizations_url":"https://api.github.com/users/zidarsk8/orgs","repos_url":"https://api.github.com/users/zidarsk8/repos","events_url":"https://api.github.com/users/zidarsk8/events{/privacy}","received_events_url":"https://api.github.com/users/zidarsk8/received_events","type":"User","site_admin":false},"body":"Opened for review","created_at":"2016-03-14T16:00:55Z","updated_at":"2016-04-05T12:50:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8df284eb5e9e4906dc959d744050020fc1a9095e","assignee":null,"milestone":{"url":"https://api.github.com/repos/google/ggrc-core/milestones/16","html_url":"https://github.com/google/ggrc-core/milestones/0.9.6-Plum%20Jelly","labels_url":"https://api.github.com/repos/google/ggrc-core/milestones/16/labels","id":1058061,"number":16,"title":"0.9.6-Plum Jelly","description":"","creator":{"login":"Smotko","id":513444,"avatar_url":"https://avatars.githubusercontent.com/u/513444?v=3","gravatar_id":"","url":"https://api.github.com/users/Smotko","html_url":"https://github.com/Smotko","followers_url":"https://api.github.com/users/Smotko/followers","following_url":"https://api.github.com/users/Smotko/following{/other_user}","gists_url":"https://api.github.com/users/Smotko/gists{/gist_id}","starred_url":"https://api.github.com/users/Smotko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Smotko/subscriptions","organizations_url":"https://api.github.com/users/Smotko/orgs","repos_url":"https://api.github.com/users/Smotko/repos","events_url":"https://api.github.com/users/Smotko/events{/privacy}","received_events_url":"https://api.github.com/users/Smotko/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":253,"state":"open","created_at":"2015-04-08T11:38:13Z","updated_at":"2016-04-04T20:33:14Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/google/ggrc-core/pulls/3662/commits","review_comments_url":"https://api.github.com/repos/google/ggrc-core/pulls/3662/comments","review_comment_url":"https://api.github.com/repos/google/ggrc-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/ggrc-core/issues/3662/comments","statuses_url":"https://api.github.com/repos/google/ggrc-core/statuses/76e2055dab82c3af03ac03e30a537900d140c306","head":{"label":"zidarsk8:feature/notifications_revamp","ref":"feature/notifications_revamp","sha":"76e2055dab82c3af03ac03e30a537900d140c306","user":{"login":"zidarsk8","id":566311,"avatar_url":"https://avatars.githubusercontent.com/u/566311?v=3","gravatar_id":"","url":"https://api.github.com/users/zidarsk8","html_url":"https://github.com/zidarsk8","followers_url":"https://api.github.com/users/zidarsk8/followers","following_url":"https://api.github.com/users/zidarsk8/following{/other_user}","gists_url":"https://api.github.com/users/zidarsk8/gists{/gist_id}","starred_url":"https://api.github.com/users/zidarsk8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zidarsk8/subscriptions","organizations_url":"https://api.github.com/users/zidarsk8/orgs","repos_url":"https://api.github.com/users/zidarsk8/repos","events_url":"https://api.github.com/users/zidarsk8/events{/privacy}","received_events_url":"https://api.github.com/users/zidarsk8/received_events","type":"User","site_admin":false},"repo":{"id":27515613,"name":"ggrc-core","full_name":"zidarsk8/ggrc-core","owner":{"login":"zidarsk8","id":566311,"avatar_url":"https://avatars.githubusercontent.com/u/566311?v=3","gravatar_id":"","url":"https://api.github.com/users/zidarsk8","html_url":"https://github.com/zidarsk8","followers_url":"https://api.github.com/users/zidarsk8/followers","following_url":"https://api.github.com/users/zidarsk8/following{/other_user}","gists_url":"https://api.github.com/users/zidarsk8/gists{/gist_id}","starred_url":"https://api.github.com/users/zidarsk8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zidarsk8/subscriptions","organizations_url":"https://api.github.com/users/zidarsk8/orgs","repos_url":"https://api.github.com/users/zidarsk8/repos","events_url":"https://api.github.com/users/zidarsk8/events{/privacy}","received_events_url":"https://api.github.com/users/zidarsk8/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zidarsk8/ggrc-core","description":"GGRC Core","fork":true,"url":"https://api.github.com/repos/zidarsk8/ggrc-core","forks_url":"https://api.github.com/repos/zidarsk8/ggrc-core/forks","keys_url":"https://api.github.com/repos/zidarsk8/ggrc-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zidarsk8/ggrc-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zidarsk8/ggrc-core/teams","hooks_url":"https://api.github.com/repos/zidarsk8/ggrc-core/hooks","issue_events_url":"https://api.github.com/repos/zidarsk8/ggrc-core/issues/events{/number}","events_url":"https://api.github.com/repos/zidarsk8/ggrc-core/events","assignees_url":"https://api.github.com/repos/zidarsk8/ggrc-core/assignees{/user}","branches_url":"https://api.github.com/repos/zidarsk8/ggrc-core/branches{/branch}","tags_url":"https://api.github.com/repos/zidarsk8/ggrc-core/tags","blobs_url":"https://api.github.com/repos/zidarsk8/ggrc-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zidarsk8/ggrc-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zidarsk8/ggrc-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/zidarsk8/ggrc-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zidarsk8/ggrc-core/statuses/{sha}","languages_url":"https://api.github.com/repos/zidarsk8/ggrc-core/languages","stargazers_url":"https://api.github.com/repos/zidarsk8/ggrc-core/stargazers","contributors_url":"https://api.github.com/repos/zidarsk8/ggrc-core/contributors","subscribers_url":"https://api.github.com/repos/zidarsk8/ggrc-core/subscribers","subscription_url":"https://api.github.com/repos/zidarsk8/ggrc-core/subscription","commits_url":"https://api.github.com/repos/zidarsk8/ggrc-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/zidarsk8/ggrc-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/zidarsk8/ggrc-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/zidarsk8/ggrc-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/zidarsk8/ggrc-core/contents/{+path}","compare_url":"https://api.github.com/repos/zidarsk8/ggrc-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zidarsk8/ggrc-core/merges","archive_url":"https://api.github.com/repos/zidarsk8/ggrc-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zidarsk8/ggrc-core/downloads","issues_url":"https://api.github.com/repos/zidarsk8/ggrc-core/issues{/number}","pulls_url":"https://api.github.com/repos/zidarsk8/ggrc-core/pulls{/number}","milestones_url":"https://api.github.com/repos/zidarsk8/ggrc-core/milestones{/number}","notifications_url":"https://api.github.com/repos/zidarsk8/ggrc-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zidarsk8/ggrc-core/labels{/name}","releases_url":"https://api.github.com/repos/zidarsk8/ggrc-core/releases{/id}","deployments_url":"https://api.github.com/repos/zidarsk8/ggrc-core/deployments","created_at":"2014-12-04T00:47:01Z","updated_at":"2016-01-11T15:13:48Z","pushed_at":"2016-04-05T12:26:35Z","git_url":"git://github.com/zidarsk8/ggrc-core.git","ssh_url":"git@github.com:zidarsk8/ggrc-core.git","clone_url":"https://github.com/zidarsk8/ggrc-core.git","svn_url":"https://github.com/zidarsk8/ggrc-core","homepage":null,"size":50552,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"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":"develop"}},"base":{"label":"google:develop","ref":"develop","sha":"64fecd4ee7df50f2aa83c8949173994df99e51d4","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":9304637,"name":"ggrc-core","full_name":"google/ggrc-core","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/ggrc-core","description":"GGRC Core","fork":false,"url":"https://api.github.com/repos/google/ggrc-core","forks_url":"https://api.github.com/repos/google/ggrc-core/forks","keys_url":"https://api.github.com/repos/google/ggrc-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/ggrc-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/ggrc-core/teams","hooks_url":"https://api.github.com/repos/google/ggrc-core/hooks","issue_events_url":"https://api.github.com/repos/google/ggrc-core/issues/events{/number}","events_url":"https://api.github.com/repos/google/ggrc-core/events","assignees_url":"https://api.github.com/repos/google/ggrc-core/assignees{/user}","branches_url":"https://api.github.com/repos/google/ggrc-core/branches{/branch}","tags_url":"https://api.github.com/repos/google/ggrc-core/tags","blobs_url":"https://api.github.com/repos/google/ggrc-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/ggrc-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/ggrc-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/ggrc-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/ggrc-core/statuses/{sha}","languages_url":"https://api.github.com/repos/google/ggrc-core/languages","stargazers_url":"https://api.github.com/repos/google/ggrc-core/stargazers","contributors_url":"https://api.github.com/repos/google/ggrc-core/contributors","subscribers_url":"https://api.github.com/repos/google/ggrc-core/subscribers","subscription_url":"https://api.github.com/repos/google/ggrc-core/subscription","commits_url":"https://api.github.com/repos/google/ggrc-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/ggrc-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/ggrc-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/ggrc-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/ggrc-core/contents/{+path}","compare_url":"https://api.github.com/repos/google/ggrc-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/ggrc-core/merges","archive_url":"https://api.github.com/repos/google/ggrc-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/ggrc-core/downloads","issues_url":"https://api.github.com/repos/google/ggrc-core/issues{/number}","pulls_url":"https://api.github.com/repos/google/ggrc-core/pulls{/number}","milestones_url":"https://api.github.com/repos/google/ggrc-core/milestones{/number}","notifications_url":"https://api.github.com/repos/google/ggrc-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/ggrc-core/labels{/name}","releases_url":"https://api.github.com/repos/google/ggrc-core/releases{/id}","deployments_url":"https://api.github.com/repos/google/ggrc-core/deployments","created_at":"2013-04-08T19:16:28Z","updated_at":"2016-03-30T08:43:33Z","pushed_at":"2016-04-05T12:46:45Z","git_url":"git://github.com/google/ggrc-core.git","ssh_url":"git@github.com:google/ggrc-core.git","clone_url":"https://github.com/google/ggrc-core.git","svn_url":"https://github.com/google/ggrc-core","homepage":null,"size":57758,"stargazers_count":81,"watchers_count":81,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":53,"mirror_url":null,"open_issues_count":16,"forks":53,"open_issues":16,"watchers":81,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/3662"},"html":{"href":"https://github.com/google/ggrc-core/pull/3662"},"issue":{"href":"https://api.github.com/repos/google/ggrc-core/issues/3662"},"comments":{"href":"https://api.github.com/repos/google/ggrc-core/issues/3662/comments"},"review_comments":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/3662/comments"},"review_comment":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/3662/commits"},"statuses":{"href":"https://api.github.com/repos/google/ggrc-core/statuses/76e2055dab82c3af03ac03e30a537900d140c306"}}}}