def test_get_pr_by_number_404(self): """ Get PR object for non-existing PR """ responses.add( responses.GET, 'https://api.github.com/repos/edx/edx-platform/pulls/1234567890', body=json.dumps({'message': 'Not Found'}), content_type='application/json; charset=utf8', status=404) with self.assertRaises(github.ObjectDoesNotExist): github.get_pr_by_number('edx/edx-platform', 1234567890)
def test_get_pr_by_number_404(self): """ Get PR object for non-existing PR """ responses.add( responses.GET, 'https://api.github.com/repos/edx/edx-platform/pulls/1234567890', body=json.dumps({'message': 'Not Found'}), content_type='application/json; charset=utf8', status=404) with self.assertRaises(requests.exceptions.HTTPError) as cm: github.get_pr_by_number('edx/edx-platform', 1234567890) self.assertEqual(cm.exception.response.status_code, 404)
def test_get_pr_by_number(self): """ Get PR object for existing PR number """ responses.add( responses.GET, 'https://api.github.com/repos/edx/edx-platform/pulls/8474', body=get_raw_fixture('github/api_pr.json'), content_type='application/json; charset=utf8', status=200) pr = github.get_pr_by_number('edx/edx-platform', 8474) self.assertEqual( pr.title, 'Add feature flag to allow hiding the discussion tab for individual courses.' ) self.assertEqual( pr.body, '**Description**\r\n\r\nHello!\nDesc with unicode «ταБЬℓσ»\r\n' '- - -\r\n**Settings**\r\n```yaml\r\nEDXAPP_FEATURES:\r\n ALLOW: true\r\n```' ) self.assertEqual(pr.number, 8474) self.assertEqual(pr.fork_name, 'open-craft/edx-platform') self.assertEqual(pr.repo_name, 'edx/edx-platform') self.assertEqual(pr.branch_name, 'smarnach/hide-discussion-tab') self.assertEqual(pr.extra_settings, 'EDXAPP_FEATURES:\r\n ALLOW: true\r\n') self.assertEqual(pr.username, 'smarnach')
def test_get_pr_by_number(self): """ Get PR object for existing PR number """ responses.add( responses.GET, 'https://api.github.com/repos/edx/edx-platform/pulls/8474', body=get_raw_fixture('github/api_pr.json'), content_type='application/json; charset=utf8', status=200) pr = github.get_pr_by_number('edx/edx-platform', 8474) self.assertEqual( pr.title, 'Add feature flag to allow hiding the discussion tab for individual courses.') self.assertEqual( pr.body, '**Description**\r\n\r\nHello!\nDesc with unicode «ταБЬℓσ»\r\n' '- - -\r\n**Settings**\r\n```yaml\r\nEDXAPP_FEATURES:\r\n ALLOW: true\r\n```') self.assertEqual(pr.number, 8474) self.assertEqual(pr.fork_name, 'open-craft/edx-platform') self.assertEqual(pr.repo_name, 'edx/edx-platform') self.assertEqual(pr.branch_name, 'smarnach/hide-discussion-tab') self.assertEqual(pr.extra_settings, 'EDXAPP_FEATURES:\r\n ALLOW: true\r\n') self.assertEqual(pr.username, 'smarnach')
def test_get_pr_by_number(self): """ Get PR object for existing PR number """ responses.add( responses.GET, "https://api.github.com/repos/edx/edx-platform/pulls/8474", body=get_raw_fixture("github/api_pr.json"), content_type="application/json; charset=utf8", status=200, ) pr = github.get_pr_by_number("edx/edx-platform", 8474) self.assertEqual(pr.title, "Add feature flag to allow hiding the discussion tab for individual courses.") self.assertEqual( pr.body, "**Description**\r\n\r\nHello!\nDesc with unicode «ταБЬℓσ»\r\n" "- - -\r\n**Settings**\r\n```yaml\r\nEDXAPP_FEATURES:\r\n ALLOW: true\r\n```", ) self.assertEqual(pr.number, 8474) self.assertEqual(pr.fork_name, "open-craft/edx-platform") self.assertEqual(pr.branch_name, "smarnach/hide-discussion-tab") self.assertEqual(pr.extra_settings, "EDXAPP_FEATURES:\r\n ALLOW: true\r\n") self.assertEqual(pr.username, "smarnach")