How to use the responses.reset function in responses

To help you get started, we’ve selected a few responses 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 codeforamerica / glossary-bot / tests / test_bot.py View on Github external
self.assertEqual(payload['channel'], "123456")
        self.assertIsNotNone(payload['icon_emoji'])

        attachment = payload['attachments'][0]
        self.assertIsNotNone(attachment)
        self.assertIsNotNone(attachment['title'])
        self.assertTrue("I don't have any definitions" in attachment['text'])
        self.assertTrue("Nobody has defined terms" in attachment['text'])
        self.assertTrue("Nobody has asked me for definitions" in attachment['text'])
        self.assertIsNotNone(attachment['color'])
        self.assertIsNotNone(attachment['fallback'])

        # delete the fake Slack webhook URL
        del(current_app.config['SLACK_WEBHOOK_URL'])
        # reset the mock
        responses.reset()
github mwclient / mwclient / tests / test_client.py View on Github external
def configure(self, version='1.24'):
        self.raw_call.return_value = self.metaResponseAsJson(version=version)
        self.site = mwclient.Site('test.wikipedia.org')
        responses.reset()
github getsentry / sentry / tests / sentry / integrations / gitlab / test_repository.py View on Github external
def test_on_delete_repository_remove_webhook(self):
        response = self.create_repository(self.default_repository_config, self.integration.id)
        responses.reset()

        responses.add(
            responses.DELETE,
            "https://example.gitlab.com/api/v4/projects/%s/hooks/99" % self.gitlab_id,
            status=204,
        )
        repo = Repository.objects.get(pk=response.data["id"])
        self.provider.on_delete_repository(repo)
        assert len(responses.calls) == 1
github AutomatedTester / Bugsy / tests / test_bugs.py View on Github external
def test_we_can_update_a_bug_with_login_token(bug_return):
  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login',
                        body='{"token": "foobar"}', status=200,
                        content_type='application/json', match_querystring=True)

  responses.add(responses.GET, rest_url('bug', 1017315),
                body=json.dumps(bug_return), status=200,
                content_type='application/json', match_querystring=True)
  bugzilla = Bugsy()
  bug = bugzilla.get(1017315)
  responses.reset()
  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315',
                body=json.dumps(bug_return), status=200,
                content_type='application/json')
  clone = Bug(bugsy=bugzilla, **bug.to_dict())
  clone.status = 'NEW'
  clone.update()
  assert clone.id == 1017315
  assert clone.status == 'RESOLVED'
github getsentry / sentry / tests / sentry / integrations / github / test_integration.py View on Github external
def _stub_github(self):
        responses.reset()

        sentry.integrations.github.integration.get_jwt = MagicMock(return_value="jwt_token_1")
        sentry.integrations.github.client.get_jwt = MagicMock(return_value="jwt_token_1")

        responses.add(
            responses.POST,
            self.base_url + "/installations/{}/access_tokens".format(self.installation_id),
            json={"token": self.access_token, "expires_at": self.expires_at},
        )

        responses.add(
            responses.GET,
            self.base_url + "/installation/repositories",
            json={
                "repositories": [
                    {"id": 1296269, "name": "foo", "full_name": "Test-Organization/foo"},
github getsentry / sentry / tests / sentry / integrations / slack / test_integration.py View on Github external
def assert_setup_flow(
        self,
        team_id="TXXXXXXX1",
        authorizing_user_id="UXXXXXXX1",
        access_token="xoxp-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx",
        access_extras=None,
        use_oauth_token_endpoint=True,
    ):
        responses.reset()

        resp = self.client.get(self.init_path)
        assert resp.status_code == 302
        redirect = urlparse(resp["Location"])
        assert redirect.scheme == "https"
        assert redirect.netloc == "slack.com"
        assert redirect.path == "/oauth/authorize"
        params = parse_qs(redirect.query)
        assert params["scope"] == [" ".join(self.provider.identity_oauth_scopes)]
        assert params["state"]
        assert params["redirect_uri"] == ["http://testserver/extensions/slack/setup/"]
        assert params["response_type"] == ["code"]
        assert params["client_id"] == ["slack-client-id"]
        # once we've asserted on it, switch to a singular values to make life
        # easier
        authorize_params = {k: v[0] for k, v in six.iteritems(params)}
github getsentry / sentry / tests / sentry / integrations / vsts / test_repository.py View on Github external
def tearDown(self):
        super(AzureDevOpsRepositoryProviderTest, self).tearDown()
        responses.reset()