{"action":"created","comment":{"url":"https://api.github.com/repos/praekelt/ndoh-control/pulls/comments/39167431","id":39167431,"diff_hunk":"@@ -97,8 +176,123 @@ def test_create_source_deny_normaluser(self):\n         self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)\n \n     def test_create_registration(self):\n-        reg_response = self.make_registration()\n+        reg_response = self.make_registration(\n+            post_data=TEST_REG_DATA[\"clinic_self\"])\n         self.assertEqual(reg_response.status_code, status.HTTP_201_CREATED)\n \n         d = Registration.objects.last()\n         self.assertEqual(d.mom_id_type, 'sa_id')\n+\n+\n+class TestJembiPostJsonTask(AuthenticatedAPITestCase):\n+\n+    def test_build_jembi_json_clinic_self(self):\n+        registration_clinic_self = self.make_registration(\n+            post_data=TEST_REG_DATA[\"clinic_self\"])\n+        reg = Registration.objects.get(pk=registration_clinic_self.data[\"id\"])\n+        expected_json_clinic_self = {\n+            'edd': '20150801',\n+            'id': '8009151234001^^^ZAF^NI',\n+            'lang': 'en',\n+            'dob': \"19800915\",\n+            'dmsisdn': None,\n+            'mha': 1,\n+            'cmsisdn': '+27001',\n+            'faccode': '12345',\n+            'encdate': '20130819144811',\n+            'type': 3,\n+            'swt': 1\n+        }\n+        json = jembi_post_json.build_jembi_json(reg)\n+        self.assertEqual(expected_json_clinic_self, json)\n+\n+    def test_build_jembi_json_clinic_hcw(self):\n+        registration_clinic_hcw = self.make_registration(\n+            post_data=TEST_REG_DATA[\"clinic_hcw\"])\n+        reg = Registration.objects.get(pk=registration_clinic_hcw.data[\"id\"])\n+        expected_json_clinic_hcw = {\n+            'edd': '20150901',\n+            'id': '5551111^^^ZW^PPN',\n+            'lang': 'af',\n+            'dob': None,\n+            'dmsisdn': \"+27820010001\",\n+            'mha': 1,\n+            'cmsisdn': '+27001',\n+            'faccode': '12345',\n+            'encdate': '20130819144811',\n+            'type': 3,\n+            'swt': 1\n+        }\n+        json = jembi_post_json.build_jembi_json(reg)\n+        self.assertEqual(expected_json_clinic_hcw, json)\n+\n+    def test_build_jembi_json_chw_self(self):\n+        registration_chw_self = self.make_registration(\n+            post_data=TEST_REG_DATA[\"chw_self\"])\n+        reg = Registration.objects.get(pk=registration_chw_self.data[\"id\"])\n+        expected_json_chw_self = {\n+            'id': '27002^^^ZAF^TEL',\n+            'lang': 'xh',\n+            'dob': \"19801015\",\n+            'dmsisdn': None,\n+            'mha': 1,\n+            'cmsisdn': '+27002',\n+            'faccode': None,\n+            'encdate': '20130819144811',\n+            'type': 2,\n+            'swt': 1\n+        }\n+        json = jembi_post_json.build_jembi_json(reg)\n+        self.assertEqual(expected_json_chw_self, json)\n+\n+    def test_build_jembi_json_chw_hcw(self):\n+        registration_chw_hcw = self.make_registration(\n+            post_data=TEST_REG_DATA[\"chw_hcw\"])\n+        reg = Registration.objects.get(pk=registration_chw_hcw.data[\"id\"])\n+        expected_json_chw_hcw = {\n+            'id': '8011151234001^^^ZAF^NI',\n+            'lang': 'zu',\n+            'dob': \"19801115\",\n+            'dmsisdn': \"+27820020002\",\n+            'mha': 1,\n+            'cmsisdn': '+27002',\n+            'faccode': None,\n+            'encdate': '20130819144811',\n+            'type': 2,\n+            'swt': 1\n+        }\n+        json = jembi_post_json.build_jembi_json(reg)\n+        self.assertEqual(expected_json_chw_hcw, json)\n+\n+    def test_build_jembi_json_personal(self):\n+        registration_personal = self.make_registration(\n+            post_data=TEST_REG_DATA[\"personal\"])\n+        reg = Registration.objects.get(pk=registration_personal.data[\"id\"])\n+        expected_json_personal = {\n+            'id': '5552222^^^MZ^PPN',\n+            'lang': 'st',\n+            'dob': None,\n+            'dmsisdn': None,\n+            'mha': 1,\n+            'cmsisdn': '+27003',\n+            'faccode': None,\n+            'encdate': '20130819144811',\n+            'type': 1,\n+            'swt': 1\n+        }\n+        json = jembi_post_json.build_jembi_json(reg)\n+        self.assertEqual(expected_json_personal, json)\n+\n+    @responses.activate\n+    def test_jembi_post_json(self):\n+        registration = self.make_registration(\n+            post_data=TEST_REG_DATA[\"clinic_self\"])\n+\n+        responses.add(responses.POST,\n+                      \"http://test/v2/json/subscription\",\n+                      body='jembi_post_json task', status=201,\n+                      content_type='application/json')\n+\n+        task_response = jembi_post_json.apply_async(\n+            kwargs={\"registration_id\": registration.data[\"id\"]})\n+        self.assertEqual(task_response.get(), 'jembi_post_json task')","path":"registration/tests.py","position":286,"original_position":286,"commit_id":"796ef859135c25726d8f286c48c1faa710d39bcd","original_commit_id":"796ef859135c25726d8f286c48c1faa710d39bcd","user":{"login":"imsickofmaps","id":1228977,"avatar_url":"https://avatars.githubusercontent.com/u/1228977?v=3","gravatar_id":"","url":"https://api.github.com/users/imsickofmaps","html_url":"https://github.com/imsickofmaps","followers_url":"https://api.github.com/users/imsickofmaps/followers","following_url":"https://api.github.com/users/imsickofmaps/following{/other_user}","gists_url":"https://api.github.com/users/imsickofmaps/gists{/gist_id}","starred_url":"https://api.github.com/users/imsickofmaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imsickofmaps/subscriptions","organizations_url":"https://api.github.com/users/imsickofmaps/orgs","repos_url":"https://api.github.com/users/imsickofmaps/repos","events_url":"https://api.github.com/users/imsickofmaps/events{/privacy}","received_events_url":"https://api.github.com/users/imsickofmaps/received_events","type":"User","site_admin":false},"body":"You've only got tests where the world is good and the inputs are well formed","created_at":"2015-09-10T14:39:23Z","updated_at":"2015-09-10T14:39:23Z","html_url":"https://github.com/praekelt/ndoh-control/pull/88#discussion_r39167431","pull_request_url":"https://api.github.com/repos/praekelt/ndoh-control/pulls/88","_links":{"self":{"href":"https://api.github.com/repos/praekelt/ndoh-control/pulls/comments/39167431"},"html":{"href":"https://github.com/praekelt/ndoh-control/pull/88#discussion_r39167431"},"pull_request":{"href":"https://api.github.com/repos/praekelt/ndoh-control/pulls/88"}}},"pull_request":{"url":"https://api.github.com/repos/praekelt/ndoh-control/pulls/88","id":44647461,"html_url":"https://github.com/praekelt/ndoh-control/pull/88","diff_url":"https://github.com/praekelt/ndoh-control/pull/88.diff","patch_url":"https://github.com/praekelt/ndoh-control/pull/88.patch","issue_url":"https://api.github.com/repos/praekelt/ndoh-control/issues/88","number":88,"state":"open","locked":false,"title":"Send registration Json to Jembi","user":{"login":"gsvr","id":3907663,"avatar_url":"https://avatars.githubusercontent.com/u/3907663?v=3","gravatar_id":"","url":"https://api.github.com/users/gsvr","html_url":"https://github.com/gsvr","followers_url":"https://api.github.com/users/gsvr/followers","following_url":"https://api.github.com/users/gsvr/following{/other_user}","gists_url":"https://api.github.com/users/gsvr/gists{/gist_id}","starred_url":"https://api.github.com/users/gsvr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsvr/subscriptions","organizations_url":"https://api.github.com/users/gsvr/orgs","repos_url":"https://api.github.com/users/gsvr/repos","events_url":"https://api.github.com/users/gsvr/events{/privacy}","received_events_url":"https://api.github.com/users/gsvr/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-10T09:50:26Z","updated_at":"2015-09-10T14:39:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ab3fc1d52f1158c4ef458a11aaf17b69e23b7e5","assignee":{"login":"gsvr","id":3907663,"avatar_url":"https://avatars.githubusercontent.com/u/3907663?v=3","gravatar_id":"","url":"https://api.github.com/users/gsvr","html_url":"https://github.com/gsvr","followers_url":"https://api.github.com/users/gsvr/followers","following_url":"https://api.github.com/users/gsvr/following{/other_user}","gists_url":"https://api.github.com/users/gsvr/gists{/gist_id}","starred_url":"https://api.github.com/users/gsvr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsvr/subscriptions","organizations_url":"https://api.github.com/users/gsvr/orgs","repos_url":"https://api.github.com/users/gsvr/repos","events_url":"https://api.github.com/users/gsvr/events{/privacy}","received_events_url":"https://api.github.com/users/gsvr/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/praekelt/ndoh-control/pulls/88/commits","review_comments_url":"https://api.github.com/repos/praekelt/ndoh-control/pulls/88/comments","review_comment_url":"https://api.github.com/repos/praekelt/ndoh-control/pulls/comments{/number}","comments_url":"https://api.github.com/repos/praekelt/ndoh-control/issues/88/comments","statuses_url":"https://api.github.com/repos/praekelt/ndoh-control/statuses/796ef859135c25726d8f286c48c1faa710d39bcd","head":{"label":"praekelt:feature/issue-88-send-registration-to-jembi","ref":"feature/issue-88-send-registration-to-jembi","sha":"796ef859135c25726d8f286c48c1faa710d39bcd","user":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"repo":{"id":21165314,"name":"ndoh-control","full_name":"praekelt/ndoh-control","owner":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekelt/ndoh-control","description":"","fork":false,"url":"https://api.github.com/repos/praekelt/ndoh-control","forks_url":"https://api.github.com/repos/praekelt/ndoh-control/forks","keys_url":"https://api.github.com/repos/praekelt/ndoh-control/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekelt/ndoh-control/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekelt/ndoh-control/teams","hooks_url":"https://api.github.com/repos/praekelt/ndoh-control/hooks","issue_events_url":"https://api.github.com/repos/praekelt/ndoh-control/issues/events{/number}","events_url":"https://api.github.com/repos/praekelt/ndoh-control/events","assignees_url":"https://api.github.com/repos/praekelt/ndoh-control/assignees{/user}","branches_url":"https://api.github.com/repos/praekelt/ndoh-control/branches{/branch}","tags_url":"https://api.github.com/repos/praekelt/ndoh-control/tags","blobs_url":"https://api.github.com/repos/praekelt/ndoh-control/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekelt/ndoh-control/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekelt/ndoh-control/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekelt/ndoh-control/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekelt/ndoh-control/statuses/{sha}","languages_url":"https://api.github.com/repos/praekelt/ndoh-control/languages","stargazers_url":"https://api.github.com/repos/praekelt/ndoh-control/stargazers","contributors_url":"https://api.github.com/repos/praekelt/ndoh-control/contributors","subscribers_url":"https://api.github.com/repos/praekelt/ndoh-control/subscribers","subscription_url":"https://api.github.com/repos/praekelt/ndoh-control/subscription","commits_url":"https://api.github.com/repos/praekelt/ndoh-control/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekelt/ndoh-control/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekelt/ndoh-control/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekelt/ndoh-control/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekelt/ndoh-control/contents/{+path}","compare_url":"https://api.github.com/repos/praekelt/ndoh-control/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekelt/ndoh-control/merges","archive_url":"https://api.github.com/repos/praekelt/ndoh-control/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekelt/ndoh-control/downloads","issues_url":"https://api.github.com/repos/praekelt/ndoh-control/issues{/number}","pulls_url":"https://api.github.com/repos/praekelt/ndoh-control/pulls{/number}","milestones_url":"https://api.github.com/repos/praekelt/ndoh-control/milestones{/number}","notifications_url":"https://api.github.com/repos/praekelt/ndoh-control/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekelt/ndoh-control/labels{/name}","releases_url":"https://api.github.com/repos/praekelt/ndoh-control/releases{/id}","created_at":"2014-06-24T13:23:02Z","updated_at":"2015-04-22T12:38:57Z","pushed_at":"2015-09-10T13:07:20Z","git_url":"git://github.com/praekelt/ndoh-control.git","ssh_url":"git@github.com:praekelt/ndoh-control.git","clone_url":"https://github.com/praekelt/ndoh-control.git","svn_url":"https://github.com/praekelt/ndoh-control","homepage":null,"size":3156,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":20,"forks":0,"open_issues":20,"watchers":0,"default_branch":"develop"}},"base":{"label":"praekelt:develop","ref":"develop","sha":"27737653c15ab065597d0cfaa2d52525a7095087","user":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"repo":{"id":21165314,"name":"ndoh-control","full_name":"praekelt/ndoh-control","owner":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekelt/ndoh-control","description":"","fork":false,"url":"https://api.github.com/repos/praekelt/ndoh-control","forks_url":"https://api.github.com/repos/praekelt/ndoh-control/forks","keys_url":"https://api.github.com/repos/praekelt/ndoh-control/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekelt/ndoh-control/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekelt/ndoh-control/teams","hooks_url":"https://api.github.com/repos/praekelt/ndoh-control/hooks","issue_events_url":"https://api.github.com/repos/praekelt/ndoh-control/issues/events{/number}","events_url":"https://api.github.com/repos/praekelt/ndoh-control/events","assignees_url":"https://api.github.com/repos/praekelt/ndoh-control/assignees{/user}","branches_url":"https://api.github.com/repos/praekelt/ndoh-control/branches{/branch}","tags_url":"https://api.github.com/repos/praekelt/ndoh-control/tags","blobs_url":"https://api.github.com/repos/praekelt/ndoh-control/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekelt/ndoh-control/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekelt/ndoh-control/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekelt/ndoh-control/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekelt/ndoh-control/statuses/{sha}","languages_url":"https://api.github.com/repos/praekelt/ndoh-control/languages","stargazers_url":"https://api.github.com/repos/praekelt/ndoh-control/stargazers","contributors_url":"https://api.github.com/repos/praekelt/ndoh-control/contributors","subscribers_url":"https://api.github.com/repos/praekelt/ndoh-control/subscribers","subscription_url":"https://api.github.com/repos/praekelt/ndoh-control/subscription","commits_url":"https://api.github.com/repos/praekelt/ndoh-control/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekelt/ndoh-control/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekelt/ndoh-control/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekelt/ndoh-control/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekelt/ndoh-control/contents/{+path}","compare_url":"https://api.github.com/repos/praekelt/ndoh-control/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekelt/ndoh-control/merges","archive_url":"https://api.github.com/repos/praekelt/ndoh-control/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekelt/ndoh-control/downloads","issues_url":"https://api.github.com/repos/praekelt/ndoh-control/issues{/number}","pulls_url":"https://api.github.com/repos/praekelt/ndoh-control/pulls{/number}","milestones_url":"https://api.github.com/repos/praekelt/ndoh-control/milestones{/number}","notifications_url":"https://api.github.com/repos/praekelt/ndoh-control/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekelt/ndoh-control/labels{/name}","releases_url":"https://api.github.com/repos/praekelt/ndoh-control/releases{/id}","created_at":"2014-06-24T13:23:02Z","updated_at":"2015-04-22T12:38:57Z","pushed_at":"2015-09-10T13:07:20Z","git_url":"git://github.com/praekelt/ndoh-control.git","ssh_url":"git@github.com:praekelt/ndoh-control.git","clone_url":"https://github.com/praekelt/ndoh-control.git","svn_url":"https://github.com/praekelt/ndoh-control","homepage":null,"size":3156,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":20,"forks":0,"open_issues":20,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/praekelt/ndoh-control/pulls/88"},"html":{"href":"https://github.com/praekelt/ndoh-control/pull/88"},"issue":{"href":"https://api.github.com/repos/praekelt/ndoh-control/issues/88"},"comments":{"href":"https://api.github.com/repos/praekelt/ndoh-control/issues/88/comments"},"review_comments":{"href":"https://api.github.com/repos/praekelt/ndoh-control/pulls/88/comments"},"review_comment":{"href":"https://api.github.com/repos/praekelt/ndoh-control/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/praekelt/ndoh-control/pulls/88/commits"},"statuses":{"href":"https://api.github.com/repos/praekelt/ndoh-control/statuses/796ef859135c25726d8f286c48c1faa710d39bcd"}}}}