{"action":"created","comment":{"url":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/comments/27870146","id":27870146,"diff_hunk":"@@ -0,0 +1,99 @@\n+# coding=utf-8\n+from global_test_case import GlobalTestCase as TestCase\n+from nuntium.models import WriteItInstance, Message\n+from subdomains.utils import reverse\n+from popit.models import Person\n+from nuntium.forms import WhoForm, DraftForm\n+\n+# This method adds a session to a request\n+# But I could not do anything with it\n+# def add_session_to_request(request):\n+#     \"\"\"Annotate a request object with a session\"\"\"\n+#     middleware = SessionMiddleware()\n+#     middleware.process_request(request)\n+#     request.session.save()\n+\n+\n+class MessageCreationTestCase(TestCase):\n+    def setUp(self):\n+        super(MessageCreationTestCase, self).setUp()\n+        self.writeitinstance = WriteItInstance.objects.get(id=1)\n+        self.person1 = Person.objects.get(id=1)\n+        self.person2 = Person.objects.get(id=2)\n+        self.writeitinstance.add_person(self.person1)\n+        self.writeitinstance.add_person(self.person2)\n+\n+    def test_step_who_doesn_have_persons_without_contacts_self_client(self):\n+        '''The who step of creating a message doesn't have a person without contacts'''\n+        self.assertTrue(self.person1.contact_set.all())\n+        self.person2.contact_set.all().delete()\n+\n+        url = reverse('write_message_step',\n+            subdomain=self.writeitinstance.slug,\n+            kwargs={'step': 'who'})\n+\n+        response = self.client.get(url)\n+        who_form = response.context['form']\n+        self.assertIsInstance(who_form, WhoForm)\n+        self.assertIn(self.person1, who_form.fields['persons'].queryset)\n+        self.assertNotIn(self.person2, who_form.fields['persons'].queryset)\n+\n+        self.assertIn('writeitinstance', response.context)\n+        self.assertEquals(response.context['writeitinstance'], self.writeitinstance)\n+        recipient1 = self.writeitinstance.persons.first()\n+        response = self.client.post(url, data={\n+            'who-persons': [recipient1.id],\n+            'write_message_view-current_step': 'who'\n+            })\n+        self.assertEquals(response.status_code, 302)\n+        url2 = reverse('write_message_step',\n+            subdomain=self.writeitinstance.slug,\n+            kwargs={'step': 'draft'})\n+        self.assertEquals(response.url, url2)\n+        response = self.client.get(url2)\n+        self.assertIsInstance(response.context['form'], DraftForm)\n+        response = self.client.post(url2, data={\n+            'draft-subject': 'This is the subjectand is very specific',\n+            'draft-content': \"This is the content\",\n+            'draft-author_name': \"Feli\",\n+            'draft-author_email': 'email@mail.com',\n+            'write_message_view-current_step': 'draft'\n+            })\n+        self.assertEquals(response.status_code, 302)","path":"nuntium/tests/message_creation_tests.py","position":62,"original_position":62,"commit_id":"5b8fa1714f2de91afb7ed94b42d4924f33f3e284","original_commit_id":"5b8fa1714f2de91afb7ed94b42d4924f33f3e284","user":{"login":"duncanparkes","id":56265,"avatar_url":"https://avatars.githubusercontent.com/u/56265?v=3","gravatar_id":"","url":"https://api.github.com/users/duncanparkes","html_url":"https://github.com/duncanparkes","followers_url":"https://api.github.com/users/duncanparkes/followers","following_url":"https://api.github.com/users/duncanparkes/following{/other_user}","gists_url":"https://api.github.com/users/duncanparkes/gists{/gist_id}","starred_url":"https://api.github.com/users/duncanparkes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duncanparkes/subscriptions","organizations_url":"https://api.github.com/users/duncanparkes/orgs","repos_url":"https://api.github.com/users/duncanparkes/repos","events_url":"https://api.github.com/users/duncanparkes/events{/privacy}","received_events_url":"https://api.github.com/users/duncanparkes/received_events","type":"User","site_admin":false},"body":"Ditto here - `assertRedirects` is your friend.","created_at":"2015-04-07T11:41:36Z","updated_at":"2015-04-07T11:41:36Z","html_url":"https://github.com/ciudadanointeligente/write-it/pull/707#discussion_r27870146","pull_request_url":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/707","_links":{"self":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/comments/27870146"},"html":{"href":"https://github.com/ciudadanointeligente/write-it/pull/707#discussion_r27870146"},"pull_request":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/707"}}},"pull_request":{"url":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/707","id":32528784,"html_url":"https://github.com/ciudadanointeligente/write-it/pull/707","diff_url":"https://github.com/ciudadanointeligente/write-it/pull/707.diff","patch_url":"https://github.com/ciudadanointeligente/write-it/pull/707.patch","issue_url":"https://api.github.com/repos/ciudadanointeligente/write-it/issues/707","number":707,"state":"open","locked":false,"title":"Issues/677 dont offer contacts for whom we dont have contacts","user":{"login":"lfalvarez","id":585757,"avatar_url":"https://avatars.githubusercontent.com/u/585757?v=3","gravatar_id":"","url":"https://api.github.com/users/lfalvarez","html_url":"https://github.com/lfalvarez","followers_url":"https://api.github.com/users/lfalvarez/followers","following_url":"https://api.github.com/users/lfalvarez/following{/other_user}","gists_url":"https://api.github.com/users/lfalvarez/gists{/gist_id}","starred_url":"https://api.github.com/users/lfalvarez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfalvarez/subscriptions","organizations_url":"https://api.github.com/users/lfalvarez/orgs","repos_url":"https://api.github.com/users/lfalvarez/repos","events_url":"https://api.github.com/users/lfalvarez/events{/privacy}","received_events_url":"https://api.github.com/users/lfalvarez/received_events","type":"User","site_admin":false},"body":"This PR filters the persons without contacts in the message creating part in the 'who' step.\r\n\r\n<!---\r\n@huboard:{\"order\":701.5625,\"milestone_order\":707,\"custom_state\":\"\"}\n-->\r\n","created_at":"2015-04-02T16:43:39Z","updated_at":"2015-04-07T11:41:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12752f5f2f1e3330a01102bc3bbd8e4fdb5a97c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/707/commits","review_comments_url":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/707/comments","review_comment_url":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ciudadanointeligente/write-it/issues/707/comments","statuses_url":"https://api.github.com/repos/ciudadanointeligente/write-it/statuses/5b8fa1714f2de91afb7ed94b42d4924f33f3e284","head":{"label":"ciudadanointeligente:issues/677-dont-offer-contacts-for-whom-we-dont-have-contacts","ref":"issues/677-dont-offer-contacts-for-whom-we-dont-have-contacts","sha":"5b8fa1714f2de91afb7ed94b42d4924f33f3e284","user":{"login":"ciudadanointeligente","id":631035,"avatar_url":"https://avatars.githubusercontent.com/u/631035?v=3","gravatar_id":"","url":"https://api.github.com/users/ciudadanointeligente","html_url":"https://github.com/ciudadanointeligente","followers_url":"https://api.github.com/users/ciudadanointeligente/followers","following_url":"https://api.github.com/users/ciudadanointeligente/following{/other_user}","gists_url":"https://api.github.com/users/ciudadanointeligente/gists{/gist_id}","starred_url":"https://api.github.com/users/ciudadanointeligente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciudadanointeligente/subscriptions","organizations_url":"https://api.github.com/users/ciudadanointeligente/orgs","repos_url":"https://api.github.com/users/ciudadanointeligente/repos","events_url":"https://api.github.com/users/ciudadanointeligente/events{/privacy}","received_events_url":"https://api.github.com/users/ciudadanointeligente/received_events","type":"Organization","site_admin":false},"repo":{"id":9037493,"name":"write-it","full_name":"ciudadanointeligente/write-it","owner":{"login":"ciudadanointeligente","id":631035,"avatar_url":"https://avatars.githubusercontent.com/u/631035?v=3","gravatar_id":"","url":"https://api.github.com/users/ciudadanointeligente","html_url":"https://github.com/ciudadanointeligente","followers_url":"https://api.github.com/users/ciudadanointeligente/followers","following_url":"https://api.github.com/users/ciudadanointeligente/following{/other_user}","gists_url":"https://api.github.com/users/ciudadanointeligente/gists{/gist_id}","starred_url":"https://api.github.com/users/ciudadanointeligente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciudadanointeligente/subscriptions","organizations_url":"https://api.github.com/users/ciudadanointeligente/orgs","repos_url":"https://api.github.com/users/ciudadanointeligente/repos","events_url":"https://api.github.com/users/ciudadanointeligente/events{/privacy}","received_events_url":"https://api.github.com/users/ciudadanointeligente/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ciudadanointeligente/write-it","description":"App to create and send messages to public persons. It's a component of POPLUS project.","fork":false,"url":"https://api.github.com/repos/ciudadanointeligente/write-it","forks_url":"https://api.github.com/repos/ciudadanointeligente/write-it/forks","keys_url":"https://api.github.com/repos/ciudadanointeligente/write-it/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ciudadanointeligente/write-it/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ciudadanointeligente/write-it/teams","hooks_url":"https://api.github.com/repos/ciudadanointeligente/write-it/hooks","issue_events_url":"https://api.github.com/repos/ciudadanointeligente/write-it/issues/events{/number}","events_url":"https://api.github.com/repos/ciudadanointeligente/write-it/events","assignees_url":"https://api.github.com/repos/ciudadanointeligente/write-it/assignees{/user}","branches_url":"https://api.github.com/repos/ciudadanointeligente/write-it/branches{/branch}","tags_url":"https://api.github.com/repos/ciudadanointeligente/write-it/tags","blobs_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/refs{/sha}","trees_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ciudadanointeligente/write-it/statuses/{sha}","languages_url":"https://api.github.com/repos/ciudadanointeligente/write-it/languages","stargazers_url":"https://api.github.com/repos/ciudadanointeligente/write-it/stargazers","contributors_url":"https://api.github.com/repos/ciudadanointeligente/write-it/contributors","subscribers_url":"https://api.github.com/repos/ciudadanointeligente/write-it/subscribers","subscription_url":"https://api.github.com/repos/ciudadanointeligente/write-it/subscription","commits_url":"https://api.github.com/repos/ciudadanointeligente/write-it/commits{/sha}","git_commits_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/commits{/sha}","comments_url":"https://api.github.com/repos/ciudadanointeligente/write-it/comments{/number}","issue_comment_url":"https://api.github.com/repos/ciudadanointeligente/write-it/issues/comments{/number}","contents_url":"https://api.github.com/repos/ciudadanointeligente/write-it/contents/{+path}","compare_url":"https://api.github.com/repos/ciudadanointeligente/write-it/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ciudadanointeligente/write-it/merges","archive_url":"https://api.github.com/repos/ciudadanointeligente/write-it/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ciudadanointeligente/write-it/downloads","issues_url":"https://api.github.com/repos/ciudadanointeligente/write-it/issues{/number}","pulls_url":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls{/number}","milestones_url":"https://api.github.com/repos/ciudadanointeligente/write-it/milestones{/number}","notifications_url":"https://api.github.com/repos/ciudadanointeligente/write-it/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ciudadanointeligente/write-it/labels{/name}","releases_url":"https://api.github.com/repos/ciudadanointeligente/write-it/releases{/id}","created_at":"2013-03-26T18:38:59Z","updated_at":"2015-04-02T16:55:30Z","pushed_at":"2015-04-06T20:01:11Z","git_url":"git://github.com/ciudadanointeligente/write-it.git","ssh_url":"git@github.com:ciudadanointeligente/write-it.git","clone_url":"https://github.com/ciudadanointeligente/write-it.git","svn_url":"https://github.com/ciudadanointeligente/write-it","homepage":"poplus.org","size":10122,"stargazers_count":19,"watchers_count":19,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":157,"forks":6,"open_issues":157,"watchers":19,"default_branch":"master"}},"base":{"label":"ciudadanointeligente:master","ref":"master","sha":"156d70056f123f6d1b4056ebe24ea2d1dab3c107","user":{"login":"ciudadanointeligente","id":631035,"avatar_url":"https://avatars.githubusercontent.com/u/631035?v=3","gravatar_id":"","url":"https://api.github.com/users/ciudadanointeligente","html_url":"https://github.com/ciudadanointeligente","followers_url":"https://api.github.com/users/ciudadanointeligente/followers","following_url":"https://api.github.com/users/ciudadanointeligente/following{/other_user}","gists_url":"https://api.github.com/users/ciudadanointeligente/gists{/gist_id}","starred_url":"https://api.github.com/users/ciudadanointeligente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciudadanointeligente/subscriptions","organizations_url":"https://api.github.com/users/ciudadanointeligente/orgs","repos_url":"https://api.github.com/users/ciudadanointeligente/repos","events_url":"https://api.github.com/users/ciudadanointeligente/events{/privacy}","received_events_url":"https://api.github.com/users/ciudadanointeligente/received_events","type":"Organization","site_admin":false},"repo":{"id":9037493,"name":"write-it","full_name":"ciudadanointeligente/write-it","owner":{"login":"ciudadanointeligente","id":631035,"avatar_url":"https://avatars.githubusercontent.com/u/631035?v=3","gravatar_id":"","url":"https://api.github.com/users/ciudadanointeligente","html_url":"https://github.com/ciudadanointeligente","followers_url":"https://api.github.com/users/ciudadanointeligente/followers","following_url":"https://api.github.com/users/ciudadanointeligente/following{/other_user}","gists_url":"https://api.github.com/users/ciudadanointeligente/gists{/gist_id}","starred_url":"https://api.github.com/users/ciudadanointeligente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciudadanointeligente/subscriptions","organizations_url":"https://api.github.com/users/ciudadanointeligente/orgs","repos_url":"https://api.github.com/users/ciudadanointeligente/repos","events_url":"https://api.github.com/users/ciudadanointeligente/events{/privacy}","received_events_url":"https://api.github.com/users/ciudadanointeligente/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ciudadanointeligente/write-it","description":"App to create and send messages to public persons. It's a component of POPLUS project.","fork":false,"url":"https://api.github.com/repos/ciudadanointeligente/write-it","forks_url":"https://api.github.com/repos/ciudadanointeligente/write-it/forks","keys_url":"https://api.github.com/repos/ciudadanointeligente/write-it/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ciudadanointeligente/write-it/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ciudadanointeligente/write-it/teams","hooks_url":"https://api.github.com/repos/ciudadanointeligente/write-it/hooks","issue_events_url":"https://api.github.com/repos/ciudadanointeligente/write-it/issues/events{/number}","events_url":"https://api.github.com/repos/ciudadanointeligente/write-it/events","assignees_url":"https://api.github.com/repos/ciudadanointeligente/write-it/assignees{/user}","branches_url":"https://api.github.com/repos/ciudadanointeligente/write-it/branches{/branch}","tags_url":"https://api.github.com/repos/ciudadanointeligente/write-it/tags","blobs_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/refs{/sha}","trees_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ciudadanointeligente/write-it/statuses/{sha}","languages_url":"https://api.github.com/repos/ciudadanointeligente/write-it/languages","stargazers_url":"https://api.github.com/repos/ciudadanointeligente/write-it/stargazers","contributors_url":"https://api.github.com/repos/ciudadanointeligente/write-it/contributors","subscribers_url":"https://api.github.com/repos/ciudadanointeligente/write-it/subscribers","subscription_url":"https://api.github.com/repos/ciudadanointeligente/write-it/subscription","commits_url":"https://api.github.com/repos/ciudadanointeligente/write-it/commits{/sha}","git_commits_url":"https://api.github.com/repos/ciudadanointeligente/write-it/git/commits{/sha}","comments_url":"https://api.github.com/repos/ciudadanointeligente/write-it/comments{/number}","issue_comment_url":"https://api.github.com/repos/ciudadanointeligente/write-it/issues/comments{/number}","contents_url":"https://api.github.com/repos/ciudadanointeligente/write-it/contents/{+path}","compare_url":"https://api.github.com/repos/ciudadanointeligente/write-it/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ciudadanointeligente/write-it/merges","archive_url":"https://api.github.com/repos/ciudadanointeligente/write-it/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ciudadanointeligente/write-it/downloads","issues_url":"https://api.github.com/repos/ciudadanointeligente/write-it/issues{/number}","pulls_url":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls{/number}","milestones_url":"https://api.github.com/repos/ciudadanointeligente/write-it/milestones{/number}","notifications_url":"https://api.github.com/repos/ciudadanointeligente/write-it/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ciudadanointeligente/write-it/labels{/name}","releases_url":"https://api.github.com/repos/ciudadanointeligente/write-it/releases{/id}","created_at":"2013-03-26T18:38:59Z","updated_at":"2015-04-02T16:55:30Z","pushed_at":"2015-04-06T20:01:11Z","git_url":"git://github.com/ciudadanointeligente/write-it.git","ssh_url":"git@github.com:ciudadanointeligente/write-it.git","clone_url":"https://github.com/ciudadanointeligente/write-it.git","svn_url":"https://github.com/ciudadanointeligente/write-it","homepage":"poplus.org","size":10122,"stargazers_count":19,"watchers_count":19,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":157,"forks":6,"open_issues":157,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/707"},"html":{"href":"https://github.com/ciudadanointeligente/write-it/pull/707"},"issue":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/issues/707"},"comments":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/issues/707/comments"},"review_comments":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/707/comments"},"review_comment":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/pulls/707/commits"},"statuses":{"href":"https://api.github.com/repos/ciudadanointeligente/write-it/statuses/5b8fa1714f2de91afb7ed94b42d4924f33f3e284"}}}}