{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/62821242","id":62821242,"diff_hunk":"@@ -49,34 +52,35 @@ def test_recipient_case_owner_location_parent(self):\n         user = CommCareUser.create(self.domain, 'test', 'test')\n         user.location_id = child_location.location_id\n         user.save()\n-        self.addCleanup(user.delete)\n \n-        case = CommCareCase(domain=self.domain, owner_id=user.get_id)\n-        case.save()\n-        self.addCleanup(case.delete)\n+        with create_test_case(self.domain, 'test-case', 'test-name', owner_id=user.get_id) as case:\n+            self.assertEqual(case.owner_id, user.get_id)\n+            handler = CaseReminderHandler(domain=self.domain, recipient=RECIPIENT_CASE_OWNER_LOCATION_PARENT)\n+            reminder = CaseReminder(domain=self.domain, case_id=case.case_id)\n \n-        handler = CaseReminderHandler(domain=self.domain, recipient=RECIPIENT_CASE_OWNER_LOCATION_PARENT)\n-        reminder = CaseReminder(domain=self.domain, case_id=case.get_id)\n+            # Test the recipient is returned correctly\n+            with patch('corehq.apps.reminders.models.CaseReminder.handler', new=handler):\n+                self.assertEqual(reminder.recipient, [parent_location])\n \n-        # Test the recipient is returned correctly\n-        with patch('corehq.apps.reminders.models.CaseReminder.handler', new=handler):\n-            self.assertEqual(reminder.recipient, [parent_location])\n+            # Remove parent location\n+            parent_location.delete()\n+            child_location.parent = None\n+            child_location.save()\n+            with patch('corehq.apps.reminders.models.CaseReminder.handler', new=handler):\n+                self.assertIsNone(reminder.recipient)\n \n-        # Remove parent location\n-        parent_location.delete()\n-        child_location.parent = None\n-        child_location.save()\n-        with patch('corehq.apps.reminders.models.CaseReminder.handler', new=handler):\n-            self.assertIsNone(reminder.recipient)\n+            # Remove child location\n+            child_location.delete()\n+            user.location_id = None\n+            user.save()\n+            with patch('corehq.apps.reminders.models.CaseReminder.handler', new=handler):\n+                self.assertIsNone(reminder.recipient)\n \n-        # Remove child location\n-        child_location.delete()\n-        user.location_id = None\n-        user.save()\n-        with patch('corehq.apps.reminders.models.CaseReminder.handler', new=handler):\n-            self.assertIsNone(reminder.recipient)\n+            # Remove case\n+            reminder.case_id = None\n+            with patch('corehq.apps.reminders.models.CaseReminder.handler', new=handler):\n+                self.assertIsNone(reminder.recipient)\n \n-        # Remove case\n-        reminder.case_id = None\n-        with patch('corehq.apps.reminders.models.CaseReminder.handler', new=handler):\n-            self.assertIsNone(reminder.recipient)\n+        parent_location_type.delete()\n+        child_location_type.delete()\n+        user.delete()","path":"corehq/apps/reminders/tests/test_recipient.py","position":106,"original_position":106,"commit_id":"62a794444491941b424cf60deb2fd16317088ac0","original_commit_id":"c46262cd1dc0082d2037b4d89783c63a6b8fcc07","user":{"login":"snopoke","id":249606,"avatar_url":"https://avatars.githubusercontent.com/u/249606?v=3","gravatar_id":"","url":"https://api.github.com/users/snopoke","html_url":"https://github.com/snopoke","followers_url":"https://api.github.com/users/snopoke/followers","following_url":"https://api.github.com/users/snopoke/following{/other_user}","gists_url":"https://api.github.com/users/snopoke/gists{/gist_id}","starred_url":"https://api.github.com/users/snopoke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snopoke/subscriptions","organizations_url":"https://api.github.com/users/snopoke/orgs","repos_url":"https://api.github.com/users/snopoke/repos","events_url":"https://api.github.com/users/snopoke/events{/privacy}","received_events_url":"https://api.github.com/users/snopoke/received_events","type":"User","site_admin":false},"body":"nit: use `self.addCleanup`","created_at":"2016-05-11T09:57:27Z","updated_at":"2016-05-11T09:57:27Z","html_url":"https://github.com/dimagi/commcare-hq/pull/11548#discussion_r62821242","pull_request_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/11548","_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/62821242"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/11548#discussion_r62821242"},"pull_request":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/11548"}}},"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/11548","id":69388991,"html_url":"https://github.com/dimagi/commcare-hq/pull/11548","diff_url":"https://github.com/dimagi/commcare-hq/pull/11548.diff","patch_url":"https://github.com/dimagi/commcare-hq/pull/11548.patch","issue_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/11548","number":11548,"state":"open","locked":false,"title":"Messaging compatibility with sql cases and forms - part 3","user":{"login":"gcapalbo","id":1028814,"avatar_url":"https://avatars.githubusercontent.com/u/1028814?v=3","gravatar_id":"","url":"https://api.github.com/users/gcapalbo","html_url":"https://github.com/gcapalbo","followers_url":"https://api.github.com/users/gcapalbo/followers","following_url":"https://api.github.com/users/gcapalbo/following{/other_user}","gists_url":"https://api.github.com/users/gcapalbo/gists{/gist_id}","starred_url":"https://api.github.com/users/gcapalbo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcapalbo/subscriptions","organizations_url":"https://api.github.com/users/gcapalbo/orgs","repos_url":"https://api.github.com/users/gcapalbo/repos","events_url":"https://api.github.com/users/gcapalbo/events{/privacy}","received_events_url":"https://api.github.com/users/gcapalbo/received_events","type":"User","site_admin":false},"body":"(opening for tests)","created_at":"2016-05-09T18:29:48Z","updated_at":"2016-05-11T09:57:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02e696ce8c29ad5a5e6a626b94639bf99061e30f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/11548/commits","review_comments_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/11548/comments","review_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/11548/comments","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/62a794444491941b424cf60deb2fd16317088ac0","head":{"label":"dimagi:messaging-sql-case-3","ref":"messaging-sql-case-3","sha":"62a794444491941b424cf60deb2fd16317088ac0","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2016-05-07T22:07:37Z","pushed_at":"2016-05-11T09:19:15Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"http://www.commcarehq.org","size":294540,"stargazers_count":70,"watchers_count":70,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":67,"mirror_url":null,"open_issues_count":50,"forks":67,"open_issues":50,"watchers":70,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"754495d5f9bcead58e85af5f855f0af9e81577f0","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2016-05-07T22:07:37Z","pushed_at":"2016-05-11T09:19:15Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"http://www.commcarehq.org","size":294540,"stargazers_count":70,"watchers_count":70,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":67,"mirror_url":null,"open_issues_count":50,"forks":67,"open_issues":50,"watchers":70,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/11548"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/11548"},"issue":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/11548"},"comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/11548/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/11548/comments"},"review_comment":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/11548/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/commcare-hq/statuses/62a794444491941b424cf60deb2fd16317088ac0"}}}}