How to use the httpretty.HTTPretty.last_request.body.decode function in httpretty

To help you get started, we’ve selected a few httpretty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linkedin / pyexchange / tests / exchange2010 / test_event_actions.py View on Github external
def test_resend_invites(self):
    HTTPretty.register_uri(HTTPretty.POST, FAKE_EXCHANGE_URL,
                           responses=[
                               self.get_change_key_response,
                               self.update_event_response,
                            ])
    self.event.resend_invitations()

    assert TEST_EVENT.change_key in HTTPretty.last_request.body.decode('utf-8')
    assert TEST_EVENT.subject not in HTTPretty.last_request.body.decode('utf-8')
github coagulant / cleanweb / test_cleanweb.py View on Github external
def assertBodyQueryString(self, **kwargs):
        """ Hakish, but works %("""
        if PY3:
            qs = parse_qs(HTTPretty.last_request.body.decode('utf-8'))
        else:
            qs = dict((key, [values[0].decode('utf-8')]) for key, values in parse_qs(HTTPretty.last_request.body).items())
        assert kwargs == qs
github linkedin / pyexchange / tests / exchange2010 / test_create_event.py View on Github external
def test_start_time(self):

    HTTPretty.register_uri(
      HTTPretty.POST, FAKE_EXCHANGE_URL,
      body=CREATE_ITEM_RESPONSE.encode('utf-8'),
      content_type='text/xml; charset=utf-8',
    )

    self.event.create()

    assert TEST_EVENT.start.strftime(EXCHANGE_DATE_FORMAT) in HTTPretty.last_request.body.decode('utf-8')
github linkedin / pyexchange / tests / exchange2010 / test_create_event.py View on Github external
def test_attendees(self):

    HTTPretty.register_uri(
      HTTPretty.POST, FAKE_EXCHANGE_URL,
      body=CREATE_ITEM_RESPONSE.encode('utf-8'),
      content_type='text/xml; charset=utf-8',
    )

    attendees = [PERSON_REQUIRED_ACCEPTED.email, PERSON_REQUIRED_TENTATIVE.email]

    self.event.attendees = attendees
    self.event.create()

    for email in attendees:
      assert email in HTTPretty.last_request.body.decode('utf-8')
github linkedin / pyexchange / tests / exchange2010 / test_update_event.py View on Github external
def test_can_remove_all_attendees(self):
    HTTPretty.register_uri(
      HTTPretty.POST,
      FAKE_EXCHANGE_URL,
      responses=[
        self.get_change_key_response,
        self.update_event_response,
      ]
    )

    self.event.attendees = None
    self.event.update()

    assert RESOURCE.email not in HTTPretty.last_request.body.decode('utf-8')
github linkedin / pyexchange / tests / exchange2010 / test_update_event.py View on Github external
def test_can_remove_all_resources(self):
    HTTPretty.register_uri(
      HTTPretty.POST,
      FAKE_EXCHANGE_URL,
      responses=[
        self.get_change_key_response,
        self.update_event_response,
      ]
    )

    self.event.resources = None
    self.event.update()

    assert RESOURCE.email not in HTTPretty.last_request.body.decode('utf-8')
github linkedin / pyexchange / tests / exchange2010 / test_update_event.py View on Github external
def test_can_set_end_time(self):

    HTTPretty.register_uri(HTTPretty.POST, FAKE_EXCHANGE_URL,
                           responses=[
                               self.get_change_key_response,
                               self.update_event_response,
                            ])
    self.event.end = TEST_EVENT_UPDATED.end
    self.event.update()

    assert TEST_EVENT_UPDATED.end.strftime(EXCHANGE_DATE_FORMAT) in HTTPretty.last_request.body.decode('utf-8')
github linkedin / pyexchange / tests / exchange2010 / test_update_event.py View on Github external
def test_can_set_location(self):

    HTTPretty.register_uri(HTTPretty.POST, FAKE_EXCHANGE_URL,
                           responses=[
                               self.get_change_key_response,
                               self.update_event_response,
                            ])

    self.event.location = TEST_EVENT_UPDATED.location
    self.event.update()

    assert TEST_EVENT_UPDATED.location in HTTPretty.last_request.body.decode('utf-8')
github stormpath / stormpath-sdk-python / tests / httprettys / test_account.py View on Github external
self.assertEqual(HTTPretty.last_request.method, "POST")
        self.assertEqual(HTTPretty.last_request.path,
            "%s/%s?expand=account" % (self.app_path, "loginAttempts"))

        httpretty.register_uri(httpretty.GET,
            self.dir_href,
            body=json.dumps(self.dir_body),
            content_type="application/json")

        directory = self.client.directories.get(self.dir_href)
        account = application.authenticate_account(
            "USERNAME", "PAŠVORD", account_store=directory)

        if isinstance(HTTPretty.last_request.body, bytes):
            req_body = json.loads(HTTPretty.last_request.body.decode())
        elif isinstance(HTTPretty.last_request.body, str):
            req_body = json.loads(HTTPretty.last_request.body)

        self.assertEqual(req_body['accountStore'], {'href': directory.href})
        self.assertEqual(HTTPretty.last_request.method, "POST")
        self.assertEqual(HTTPretty.last_request.path,
            "%s/%s" % (self.app_path, "loginAttempts"))