How to use the responses.activate 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 watson-developer-cloud / python-sdk / test / unit / test_personality_insights_v3.py View on Github external
@responses.activate
def test_json_to_csv():

    authenticator = BasicAuthenticator('username', 'password')
    personality_insights = ibm_watson.PersonalityInsightsV3('2016-10-20', authenticator=authenticator)

    with open(os.path.join(os.path.dirname(__file__), '../../resources/personality-v3-expect3.txt')) as expect_file:
        profile_response = expect_file.read()

    responses.add(responses.POST, profile_url,
                  body=profile_response, status=200,
                  content_type='text/csv')

    with open(os.path.join(os.path.dirname(__file__), '../../resources/personality-v3.json')) as personality_text:
        personality_insights.profile(
            personality_text,
            'text/csv',
github canonical-web-and-design / snapcraft.io / tests / publisher / tests_account_snaps.py View on Github external
    @responses.activate
    def test_revoked_snaps(self):
        payload = {
            "snaps": {
                "16": {
                    "test": {
                        "status": "Approved",
                        "snap-id": "1",
                        "snap-name": "test",
                        "latest_revisions": [
                            {
                                "test": "test",
                                "since": "2018-01-01T00:00:00Z",
                                "channels": [],
                            }
                        ],
                    },
github macacajs / wd.py / tests / macaca / test_webdriver.py View on Github external
@responses.activate
def test_execute_script(driver, element):
    responses.add(
        responses.POST,
        'http://127.0.0.1:3456/wd/hub/session/2345/execute',
        json={
            'status': 0,
            'sessionId': '2345',
            'value': 'input'
        })
    assert driver.execute_script(
        'return arguments[0].tagName', element) == 'input'
    body = responses.calls[0].request.body.decode('utf-8')
    assert json.loads(body) == {
        'script': 'return arguments[0].tagName',
        'args': [{"ELEMENT": "1"}]
    }
github getsentry / sentry / tests / sentry / mediators / sentry_app_installations / test_creator.py View on Github external
    @responses.activate
    def test_installed_status(self):
        responses.add(responses.POST, "https://example.com/webhook")
        internal_app = self.create_internal_integration(name="internal", organization=self.org)
        creator = Creator(organization=self.org, slug=internal_app.slug, user=self.user)
        install = creator.call()

        assert install.status == SentryAppInstallationStatus.INSTALLED
github HwangWonYo / naver_talk_sdk / tests / api / test_persistent_menu.py View on Github external
    @responses.activate
    def test_persistent_menu(self):
        responses.add(
            responses.POST,
            NaverTalkApi.DEFAULT_API_ENDPOINT,
            json={
                "success": True,
                "resultCode": "00"
            },
            status=200
        )

        counter = mock.MagicMock()
        def test_callback(res, payload):
            self.assertEqual(
                payload,
                {
github watson-developer-cloud / python-sdk / test / unit / test_language_translator_v2.py View on Github external
@responses.activate
def test_translate_model_id():
    service = watson_developer_cloud.LanguageTranslatorV2(
        username='username', password='password')
    endpoint = '/v2/translate'
    url = '{0}{1}'.format(base_url, endpoint)
    expected = {
        "character_count": 22,
        "translations": [
            {
                "translation": "Messi es el mejor"
            }
        ],
        "word_count": 5
    }
    responses.add(
        responses.POST,
github watson-developer-cloud / python-sdk / test / unit / test_assistant_v1.py View on Github external
@responses.activate
def test_create_counterexample():
    endpoint = '/v1/workspaces/{0}/counterexamples'.format('boguswid')
    url = '{0}{1}'.format(base_url, endpoint)
    response = {
        "text": "I want financial advice today.",
        "created": "2016-07-11T16:39:01.774Z",
        "updated": "2015-12-07T18:53:59.153Z"
    }
    responses.add(
        responses.POST,
        url,
        body=json.dumps(response),
        status=201,
        content_type='application/json')
    authenticator = BasicAuthenticator('username', 'password')
    service = ibm_watson.AssistantV1(version='2017-02-03', authenticator=authenticator)
github Cloud-CV / evalai-cli / tests / test_teams.py View on Github external
    @responses.activate
    def test_create_host_team_for_option_yes_with_invalid_team_url(self):
        output = (
            "Enter team name: TeamTest\n"
            "Please confirm the team name - TeamTest [y/N]: y\n"
            "Do you want to enter the Team URL [y/N]: Y\n"
            "Team URL: TestURL\n"
            "Sorry, please enter a valid link.\n"
            "Team URL: http://testteam.com\n"
            "\nYour host team TestTeam was successfully created."
        )
        runner = CliRunner()
        result = runner.invoke(
            teams,
            ["create", "host"],
            input="TeamTest\ny\nY\nTestURL\nhttp://testteam.com",
        )
github tsifrer / python-twitch-client / tests / api / test_communities.py View on Github external
@responses.activate
def test_create_avatar_image():
    community_id = 'abcd'
    responses.add(responses.POST,
                  '{}communities/{}/images/avatar'.format(BASE_URL, community_id),
                  status=204,
                  content_type='application/json')

    client = TwitchClient('client id', 'oauth token')

    client.communities.create_avatar_image(community_id, 'imagecontent')

    assert len(responses.calls) == 1
github pantsbuild / pants / tests / python / pants_test / cache / test_pinger.py View on Github external
  @responses.activate
  def test_global_pinger_memo(self):
    urls = [self.slow_url]
    with self.pinger(timeout=0.2, urls=urls) as fast_pinger:
      self.assertEqual(fast_pinger.pings([self.slow_url])[0][1], Pinger.UNREACHABLE)
    with self.pinger(timeout=0.4, urls=urls) as slow_pinger:
      self.assertLess(slow_pinger.pings([self.slow_url])[0][1], Pinger.UNREACHABLE)