How to use the httpretty.HTTPretty.POST 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 python-social-auth / social-app-django / tests / oauth2.py View on Github external
'redirect_state=' + start_query['redirect_state']
        else:
            location_url = target_url
        location_query = parse_qs(urlparse(location_url).query)

        HTTPretty.register_uri(HTTPretty.GET, start_url, status=301,
                               location=location_url)
        HTTPretty.register_uri(HTTPretty.GET, location_url, status=200,
                               body='foobar')

        response = requests.get(start_url)
        expect(response.url).to.equal(location_url)
        expect(response.text).to.equal('foobar')

        method = self.backend.ACCESS_TOKEN_METHOD == 'GET' and HTTPretty.GET \
                                                            or HTTPretty.POST
        HTTPretty.register_uri(method,
                               uri=self.backend.ACCESS_TOKEN_URL,
                               status=200,
                               body=self.access_token_body or '',
                               content_type=self.user_data_content_type)

        if self.user_data_url:
            HTTPretty.register_uri(HTTPretty.GET, self.user_data_url,
                                   body=self.user_data_body or '',
                                   content_type=self.user_data_content_type)
        self.strategy.set_request_data(location_query)
github rackerlabs / python-cloudbackup-sdk / tests / unit / test_restore.py View on Github external
def test_start_works(self):
        url = '{0}/restore/action-requested'.format(self.connection.host)
        HTTPretty.register_uri(HTTPretty.POST, url)
        self.cmd.start()
github linkedin / pyexchange / tests / exchange2010 / test_list_events.py View on Github external
def setUp(self):
        HTTPretty.register_uri(
            HTTPretty.POST, FAKE_EXCHANGE_URL,
            body=LIST_EVENTS_RESPONSE.encode('utf-8'),
            content_type='text/xml; charset=utf-8'
        )
        self.event_list = self.service.calendar().list_events(
            start=TEST_EVENT_LIST_START,
            end=TEST_EVENT_LIST_END
        )
github linkedin / pyexchange / tests / exchange2010 / test_move_folder.py View on Github external
def test_move(self):

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

    self.folder.move_to('AABBCCDDEEFFGG==')
    assert self.folder.parent_id == 'AABBCCDDEEFFGG=='
github python-social-auth / social-app-django / tests / base.py View on Github external
def pipeline_handlers(self, url):
        HTTPretty.register_uri(HTTPretty.GET, url, status=200, body='foobar')
        HTTPretty.register_uri(HTTPretty.POST, url, status=200)
github rackerlabs / python-cloudbackup-sdk / tests / unit / client / test_agent.py View on Github external
def _mock_auth(status):
    reply = mock_auth.authenticate()
    HTTPretty.register_uri(HTTPretty.POST, IDENTITY_TOKEN_URL,
                           status=status, body=json.dumps(reply))
github linkedin / pyexchange / tests / exchange2010 / test_move_event.py View on Github external
def test_move(self):

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

    self.event.move_to('AAAhKSe7AAA=')
    assert self.event.calendar_id == 'AAAhKSe7AAA='
    assert self.event.id == TEST_EVENT_MOVED.id
github linkedin / pyexchange / tests / exchange2010 / test_create_folder.py View on Github external
def test_can_set_display_name(self):

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

    self.folder.display_name = TEST_FOLDER.display_name
    self.folder.parent_id = TEST_FOLDER.parent_id
    self.folder.create()

    assert TEST_FOLDER.display_name 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_subject(self):

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

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

    assert TEST_EVENT_UPDATED.subject in HTTPretty.last_request.body.decode('utf-8')
github linkedin / pyexchange / tests / exchange2010 / test_event_actions.py View on Github external
def setUp(self):
    HTTPretty.register_uri(HTTPretty.POST, FAKE_EXCHANGE_URL,
                                 body=GET_ITEM_RESPONSE.encode('utf-8'),
                                 content_type='text/xml; charset=utf-8')

    self.event = self.service.calendar().get_event(id=TEST_EVENT.id)