Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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',
@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": [],
}
],
},
@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"}]
}
@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
@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,
{
@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,
@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)
@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",
)
@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
@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)