예제 #1
0
 def test_build_formdata_with_add_metadata(self):
     """The data body sent to GitHub API, with additional metadata."""
     # we just need to test that nothing breaks
     # even if the data are empty
     form_object = {'foo': 'bar'}
     form_object = form.add_metadata(
         form_object, {'public_url': 'https://public.example.com'})
     actual = form.build_formdata(form_object)
     expected = {
         'body':
         '<!-- @browser: None -->\n<!-- @ua_header: None -->\n<!-- @reported_with: None -->\n<!-- @public_url: https://public.example.com -->\n\n**URL**: None\n\n**Browser / Version**: None\n**Operating System**: None\n**Tested Another Browser**: Unknown \n\n**Problem type**: Unknown\n**Description**: None\n**Steps to Reproduce**:\nNone\n\n\n\n_From [webcompat.com](https://webcompat.com/) with \u2764\ufe0f_',
         'title': 'None - unknown'
     }  # noqa
     self.assertIs(type(actual), dict)
     self.assertEqual(actual, expected)
     form_object2 = form.add_metadata(form_object, {'foo': 'bar'})
     actual2 = form.build_formdata(form_object2)
     expected = {
         'body':
         '<!-- @browser: None -->\n<!-- @ua_header: None -->\n<!-- @reported_with: None -->\n<!-- @foo: bar -->\n\n**URL**: None\n\n**Browser / Version**: None\n**Operating System**: None\n**Tested Another Browser**: Unknown \n\n**Problem type**: Unknown\n**Description**: None\n**Steps to Reproduce**:\nNone\n\n\n\n_From [webcompat.com](https://webcompat.com/) with \u2764\ufe0f_',
         'title': 'None - unknown'
     }  # noqa
     self.assertIs(type(actual2), dict)
     self.assertEqual(actual2, expected)
     form_object3 = form.add_metadata(form_object, {'😀': '😅'})
     actual3 = form.build_formdata(form_object3)
     expected = {
         'body':
         '<!-- @browser: None -->\n<!-- @ua_header: None -->\n<!-- @reported_with: None -->\n<!-- @😀: 😅 -->\n\n**URL**: None\n\n**Browser / Version**: None\n**Operating System**: None\n**Tested Another Browser**: Unknown \n\n**Problem type**: Unknown\n**Description**: None\n**Steps to Reproduce**:\nNone\n\n\n\n_From [webcompat.com](https://webcompat.com/) with \u2764\ufe0f_',
         'title': 'None - unknown'
     }  # noqa
     self.assertIs(type(actual3), dict)
     self.assertEqual(actual3, expected)
예제 #2
0
def report_private_issue(form, public_url):
    """Report the issue privately.

    This also allows us to pass in public_url metadata, to be
    embedded in the issue body.

    Returns None (so we don't accidentally leak data).
    """
    path = 'repos/{0}'.format(PRIVATE_REPO_URI)
    milestone = PRIVATE_REPO_MILESTONE
    form = add_metadata(form, {'public_url': public_url})
    formdata = build_formdata(form)
    # add the milestone number to set
    formdata['milestone'] = milestone
    proxy_request('post', path, data=json.dumps(formdata))
    return None