{"action":"created","comment":{"url":"https://api.github.com/repos/gitcoinco/web/pulls/comments/173573728","pull_request_review_id":102786832,"id":173573728,"diff_hunk":"@@ -0,0 +1,92 @@\n+# -*- coding: utf-8 -*-\n+\"\"\"Handle gas util related tests.\n+\n+Copyright (C) 2018 Gitcoin Core\n+\n+This program is free software: you can redistribute it and/or modify\n+it under the terms of the GNU Affero General Public License as published\n+by the Free Software Foundation, either version 3 of the License, or\n+(at your option) any later version.\n+\n+This program is distributed in the hope that it will be useful,\n+but WITHOUT ANY WARRANTY; without even the implied warranty of\n+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+GNU Affero General Public License for more details.\n+\n+You should have received a copy of the GNU Affero General Public License\n+along with this program. If not, see <http://www.gnu.org/licenses/>.\n+\n+\"\"\"\n+from django.test import TestCase\n+\n+from marketing.models import EmailSubscriber, Stat\n+from marketing.utils import get_or_save_email_subscriber, get_stat, should_suppress_notification_email\n+\n+\n+class MarketingStatUtilsTest(TestCase):\n+    \"\"\"Define tests for marketing utils.\"\"\"\n+\n+    def setUp(self):\n+        \"\"\"Perform setup for the testcase.\"\"\"\n+        Stat.objects.create(\n+            key='mykey',\n+            val=1\n+        )\n+        Stat.objects.create(\n+            key='mykey',\n+            val=2\n+        )\n+\n+    def test_get_stat(self):\n+        \"\"\"Test the marketing util get_stat method.\"\"\"\n+        assert get_stat('mykey') == 2\n+\n+class MarketingEmailUtilsTest(TestCase):\n+    \"\"\"Define tests for marketing email utils.\"\"\"\n+\n+    def setUp(self):\n+        \"\"\"Perform setup for the testcase.\"\"\"\n+        EmailSubscriber.objects.create(\n+            email='emailSubscriber1@gitcoin.co',\n+            source='mysource',\n+            priv='priv1'\n+        )\n+        EmailSubscriber.objects.create(\n+            email='emailSubscriber2@gitcoin.co',\n+            source='mysource',\n+            preferences={\n+                'level': 'something'\n+            }\n+        )\n+        EmailSubscriber.objects.create(\n+            email='emailSubscriber3@gitcoin.co',\n+            source='mysource',\n+            preferences={\n+                'level': 'nothing'\n+            }\n+        )\n+\n+\n+    def test_should_suppress_notification_email(self):\n+        \"\"\"Test the marketing util test_should_suppress_notification_email method.\"\"\"\n+        assert should_suppress_notification_email('emailSubscriber1@gitcoin.co') == False\n+        assert should_suppress_notification_email('emailSubscriber2@gitcoin.co') == False\n+        assert should_suppress_notification_email('emailSubscriber3@gitcoin.co') == True\n+\n+    def test_get_of_get_or_save_email_subscriber(self):\n+        \"\"\"Test the marketing util get_or_save_email_subscriber method.\"\"\"\n+        assert get_or_save_email_subscriber('emailSubscriber1@gitcoin.co', 'mysource') == 'priv1'\n+\n+        emailSubscriber1SecondSource = EmailSubscriber.objects.create(\n+            email='emailSubscriber1@gitcoin.co',\n+            source='secondsource',\n+            priv='priv2'\n+        )\n+\n+        assert get_or_save_email_subscriber('emailSubscriber1@gitcoin.co', 'secondsource') == 'priv1'\n+\n+    def test_save_get_or_save_email_subscriber_get(self):\n+        \"\"\"Test the marketing util get_or_save_email_subscriber method.\"\"\"\n+        self.assertIsNotNone(get_or_save_email_subscriber('newemail@gitcoin.co',\n+            'mysource', send_slack_invite=False))","path":"app/marketing/tests/test_marketing_utils.py","position":91,"original_position":91,"commit_id":"79623c6a113dd2e295101882ebd08c0727609928","original_commit_id":"79623c6a113dd2e295101882ebd08c0727609928","user":{"login":"mbeacom","id":7315957,"avatar_url":"https://avatars0.githubusercontent.com/u/7315957?v=4","gravatar_id":"","url":"https://api.github.com/users/mbeacom","html_url":"https://github.com/mbeacom","followers_url":"https://api.github.com/users/mbeacom/followers","following_url":"https://api.github.com/users/mbeacom/following{/other_user}","gists_url":"https://api.github.com/users/mbeacom/gists{/gist_id}","starred_url":"https://api.github.com/users/mbeacom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbeacom/subscriptions","organizations_url":"https://api.github.com/users/mbeacom/orgs","repos_url":"https://api.github.com/users/mbeacom/repos","events_url":"https://api.github.com/users/mbeacom/events{/privacy}","received_events_url":"https://api.github.com/users/mbeacom/received_events","type":"User","site_admin":false},"body":"Can you carry this indent over to hang below `(get_or_save`?","created_at":"2018-03-09T21:33:14Z","updated_at":"2018-03-09T21:33:29Z","html_url":"https://github.com/gitcoinco/web/pull/524#discussion_r173573728","pull_request_url":"https://api.github.com/repos/gitcoinco/web/pulls/524","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/gitcoinco/web/pulls/comments/173573728"},"html":{"href":"https://github.com/gitcoinco/web/pull/524#discussion_r173573728"},"pull_request":{"href":"https://api.github.com/repos/gitcoinco/web/pulls/524"}}},"pull_request":{"url":"https://api.github.com/repos/gitcoinco/web/pulls/524","id":172735241,"html_url":"https://github.com/gitcoinco/web/pull/524","diff_url":"https://github.com/gitcoinco/web/pull/524.diff","patch_url":"https://github.com/gitcoinco/web/pull/524.patch","issue_url":"https://api.github.com/repos/gitcoinco/web/issues/524","number":524,"state":"open","locked":false,"title":"Writing coverage for marketing model, increasing coverage to 33%","user":{"login":"leonprou","id":7228844,"avatar_url":"https://avatars3.githubusercontent.com/u/7228844?v=4","gravatar_id":"","url":"https://api.github.com/users/leonprou","html_url":"https://github.com/leonprou","followers_url":"https://api.github.com/users/leonprou/followers","following_url":"https://api.github.com/users/leonprou/following{/other_user}","gists_url":"https://api.github.com/users/leonprou/gists{/gist_id}","starred_url":"https://api.github.com/users/leonprou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonprou/subscriptions","organizations_url":"https://api.github.com/users/leonprou/orgs","repos_url":"https://api.github.com/users/leonprou/repos","events_url":"https://api.github.com/users/leonprou/events{/privacy}","received_events_url":"https://api.github.com/users/leonprou/received_events","type":"User","site_admin":false},"body":"##### Description\r\nAdding tests to increase code coverage from 28% to 33%. Testing marketing module.\r\n\r\n##### Checklist\r\n\r\n- [ ] linter status: 100% pass.\r\n- [x] changes don't break existing behavior\r\n- [x] commit message follows [commit guidelines](https://github.com/gitcoinco/web/blob/master/docs/CONTRIBUTING.md#step-4-commit)\r\n\r\n##### Affected core subsystem(s)\r\nmarketing\r\n\r\n##### Testing\r\nThis PR is increasing test coverage. Only one little refactor was made.\r\n\r\n#####  Refers/Fixes\r\n[#408](https://github.com/gitcoinco/web/issues/408)","created_at":"2018-03-04T19:11:08Z","updated_at":"2018-03-09T21:33:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4888c163a338168394c59cc6caaae3b7afdfb1fb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":817787973,"url":"https://api.github.com/repos/gitcoinco/web/labels/backend","name":"backend","color":"a82351","default":false},{"id":820453554,"url":"https://api.github.com/repos/gitcoinco/web/labels/needs%20review","name":"needs review","color":"73dff4","default":false},{"id":805733893,"url":"https://api.github.com/repos/gitcoinco/web/labels/needs-testing","name":"needs-testing","color":"f490db","default":false},{"id":857992682,"url":"https://api.github.com/repos/gitcoinco/web/labels/tests","name":"tests","color":"efd8a2","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/gitcoinco/web/pulls/524/commits","review_comments_url":"https://api.github.com/repos/gitcoinco/web/pulls/524/comments","review_comment_url":"https://api.github.com/repos/gitcoinco/web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gitcoinco/web/issues/524/comments","statuses_url":"https://api.github.com/repos/gitcoinco/web/statuses/79623c6a113dd2e295101882ebd08c0727609928","head":{"label":"leonprou:increase_code_coverage","ref":"increase_code_coverage","sha":"79623c6a113dd2e295101882ebd08c0727609928","user":{"login":"leonprou","id":7228844,"avatar_url":"https://avatars3.githubusercontent.com/u/7228844?v=4","gravatar_id":"","url":"https://api.github.com/users/leonprou","html_url":"https://github.com/leonprou","followers_url":"https://api.github.com/users/leonprou/followers","following_url":"https://api.github.com/users/leonprou/following{/other_user}","gists_url":"https://api.github.com/users/leonprou/gists{/gist_id}","starred_url":"https://api.github.com/users/leonprou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonprou/subscriptions","organizations_url":"https://api.github.com/users/leonprou/orgs","repos_url":"https://api.github.com/users/leonprou/repos","events_url":"https://api.github.com/users/leonprou/events{/privacy}","received_events_url":"https://api.github.com/users/leonprou/received_events","type":"User","site_admin":false},"repo":{"id":122614095,"name":"web","full_name":"leonprou/web","owner":{"login":"leonprou","id":7228844,"avatar_url":"https://avatars3.githubusercontent.com/u/7228844?v=4","gravatar_id":"","url":"https://api.github.com/users/leonprou","html_url":"https://github.com/leonprou","followers_url":"https://api.github.com/users/leonprou/followers","following_url":"https://api.github.com/users/leonprou/following{/other_user}","gists_url":"https://api.github.com/users/leonprou/gists{/gist_id}","starred_url":"https://api.github.com/users/leonprou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonprou/subscriptions","organizations_url":"https://api.github.com/users/leonprou/orgs","repos_url":"https://api.github.com/users/leonprou/repos","events_url":"https://api.github.com/users/leonprou/events{/privacy}","received_events_url":"https://api.github.com/users/leonprou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/leonprou/web","description":"Push Open Source Forward.","fork":true,"url":"https://api.github.com/repos/leonprou/web","forks_url":"https://api.github.com/repos/leonprou/web/forks","keys_url":"https://api.github.com/repos/leonprou/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leonprou/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leonprou/web/teams","hooks_url":"https://api.github.com/repos/leonprou/web/hooks","issue_events_url":"https://api.github.com/repos/leonprou/web/issues/events{/number}","events_url":"https://api.github.com/repos/leonprou/web/events","assignees_url":"https://api.github.com/repos/leonprou/web/assignees{/user}","branches_url":"https://api.github.com/repos/leonprou/web/branches{/branch}","tags_url":"https://api.github.com/repos/leonprou/web/tags","blobs_url":"https://api.github.com/repos/leonprou/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leonprou/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leonprou/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/leonprou/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leonprou/web/statuses/{sha}","languages_url":"https://api.github.com/repos/leonprou/web/languages","stargazers_url":"https://api.github.com/repos/leonprou/web/stargazers","contributors_url":"https://api.github.com/repos/leonprou/web/contributors","subscribers_url":"https://api.github.com/repos/leonprou/web/subscribers","subscription_url":"https://api.github.com/repos/leonprou/web/subscription","commits_url":"https://api.github.com/repos/leonprou/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/leonprou/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/leonprou/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/leonprou/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/leonprou/web/contents/{+path}","compare_url":"https://api.github.com/repos/leonprou/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leonprou/web/merges","archive_url":"https://api.github.com/repos/leonprou/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leonprou/web/downloads","issues_url":"https://api.github.com/repos/leonprou/web/issues{/number}","pulls_url":"https://api.github.com/repos/leonprou/web/pulls{/number}","milestones_url":"https://api.github.com/repos/leonprou/web/milestones{/number}","notifications_url":"https://api.github.com/repos/leonprou/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leonprou/web/labels{/name}","releases_url":"https://api.github.com/repos/leonprou/web/releases{/id}","deployments_url":"https://api.github.com/repos/leonprou/web/deployments","created_at":"2018-02-23T11:41:13Z","updated_at":"2018-02-23T11:41:17Z","pushed_at":"2018-03-09T14:03:43Z","git_url":"git://github.com/leonprou/web.git","ssh_url":"git@github.com:leonprou/web.git","clone_url":"https://github.com/leonprou/web.git","svn_url":"https://github.com/leonprou/web","homepage":"https://gitcoin.co","size":143966,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gitcoinco:master","ref":"master","sha":"e4ef10e05eb761623886b86eaf16ed36cdb2922e","user":{"login":"gitcoinco","id":30044474,"avatar_url":"https://avatars1.githubusercontent.com/u/30044474?v=4","gravatar_id":"","url":"https://api.github.com/users/gitcoinco","html_url":"https://github.com/gitcoinco","followers_url":"https://api.github.com/users/gitcoinco/followers","following_url":"https://api.github.com/users/gitcoinco/following{/other_user}","gists_url":"https://api.github.com/users/gitcoinco/gists{/gist_id}","starred_url":"https://api.github.com/users/gitcoinco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitcoinco/subscriptions","organizations_url":"https://api.github.com/users/gitcoinco/orgs","repos_url":"https://api.github.com/users/gitcoinco/repos","events_url":"https://api.github.com/users/gitcoinco/events{/privacy}","received_events_url":"https://api.github.com/users/gitcoinco/received_events","type":"Organization","site_admin":false},"repo":{"id":96767206,"name":"web","full_name":"gitcoinco/web","owner":{"login":"gitcoinco","id":30044474,"avatar_url":"https://avatars1.githubusercontent.com/u/30044474?v=4","gravatar_id":"","url":"https://api.github.com/users/gitcoinco","html_url":"https://github.com/gitcoinco","followers_url":"https://api.github.com/users/gitcoinco/followers","following_url":"https://api.github.com/users/gitcoinco/following{/other_user}","gists_url":"https://api.github.com/users/gitcoinco/gists{/gist_id}","starred_url":"https://api.github.com/users/gitcoinco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitcoinco/subscriptions","organizations_url":"https://api.github.com/users/gitcoinco/orgs","repos_url":"https://api.github.com/users/gitcoinco/repos","events_url":"https://api.github.com/users/gitcoinco/events{/privacy}","received_events_url":"https://api.github.com/users/gitcoinco/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gitcoinco/web","description":"Push Open Source Forward.","fork":false,"url":"https://api.github.com/repos/gitcoinco/web","forks_url":"https://api.github.com/repos/gitcoinco/web/forks","keys_url":"https://api.github.com/repos/gitcoinco/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gitcoinco/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gitcoinco/web/teams","hooks_url":"https://api.github.com/repos/gitcoinco/web/hooks","issue_events_url":"https://api.github.com/repos/gitcoinco/web/issues/events{/number}","events_url":"https://api.github.com/repos/gitcoinco/web/events","assignees_url":"https://api.github.com/repos/gitcoinco/web/assignees{/user}","branches_url":"https://api.github.com/repos/gitcoinco/web/branches{/branch}","tags_url":"https://api.github.com/repos/gitcoinco/web/tags","blobs_url":"https://api.github.com/repos/gitcoinco/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gitcoinco/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gitcoinco/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/gitcoinco/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gitcoinco/web/statuses/{sha}","languages_url":"https://api.github.com/repos/gitcoinco/web/languages","stargazers_url":"https://api.github.com/repos/gitcoinco/web/stargazers","contributors_url":"https://api.github.com/repos/gitcoinco/web/contributors","subscribers_url":"https://api.github.com/repos/gitcoinco/web/subscribers","subscription_url":"https://api.github.com/repos/gitcoinco/web/subscription","commits_url":"https://api.github.com/repos/gitcoinco/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/gitcoinco/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/gitcoinco/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/gitcoinco/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/gitcoinco/web/contents/{+path}","compare_url":"https://api.github.com/repos/gitcoinco/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gitcoinco/web/merges","archive_url":"https://api.github.com/repos/gitcoinco/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gitcoinco/web/downloads","issues_url":"https://api.github.com/repos/gitcoinco/web/issues{/number}","pulls_url":"https://api.github.com/repos/gitcoinco/web/pulls{/number}","milestones_url":"https://api.github.com/repos/gitcoinco/web/milestones{/number}","notifications_url":"https://api.github.com/repos/gitcoinco/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gitcoinco/web/labels{/name}","releases_url":"https://api.github.com/repos/gitcoinco/web/releases{/id}","deployments_url":"https://api.github.com/repos/gitcoinco/web/deployments","created_at":"2017-07-10T10:53:45Z","updated_at":"2018-03-09T19:42:01Z","pushed_at":"2018-03-09T21:11:08Z","git_url":"git://github.com/gitcoinco/web.git","ssh_url":"git@github.com:gitcoinco/web.git","clone_url":"https://github.com/gitcoinco/web.git","svn_url":"https://github.com/gitcoinco/web","homepage":"https://gitcoin.co","size":146047,"stargazers_count":176,"watchers_count":176,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":108,"mirror_url":null,"archived":false,"open_issues_count":230,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":108,"open_issues":230,"watchers":176,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gitcoinco/web/pulls/524"},"html":{"href":"https://github.com/gitcoinco/web/pull/524"},"issue":{"href":"https://api.github.com/repos/gitcoinco/web/issues/524"},"comments":{"href":"https://api.github.com/repos/gitcoinco/web/issues/524/comments"},"review_comments":{"href":"https://api.github.com/repos/gitcoinco/web/pulls/524/comments"},"review_comment":{"href":"https://api.github.com/repos/gitcoinco/web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gitcoinco/web/pulls/524/commits"},"statuses":{"href":"https://api.github.com/repos/gitcoinco/web/statuses/79623c6a113dd2e295101882ebd08c0727609928"}},"author_association":"NONE"}}
{"actor":{"display_login":"mbeacom"}}