Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@mock_responses.activate
def test_format_inline_images_with_many_img_tags(self):
self.givenTestImage()
input_email = {'body': '<div><img src="http://test-url.png"><img src="http://test-url.png"></div>'}
output_email = email_parser.format_inline_images(input_email, self.fail_if_called)
self.assertHasCount(output_email['body'], 'src="data:', 2)
@responses.activate
def test_call_raises_custom_error(self):
client = Client()
responses.add(
responses.POST, client.server, json={"error": {"code": 1, "message": "Custom message"}}, status=200
)
with pytest.raises(ClientException, match=r"Custom message") as e:
client.call("aria2.method")
assert e.code == 1
@responses.activate
def test_insert_secret_with_aria2_method_call(self):
# create client with secret
secret = "hello"
client = Client(secret=secret)
responses.add_callback(responses.POST, client.server, callback=self.call_params_callback)
# create params
params = ["param1", "param2"]
# copy params and insert secret
expected_params = deepcopy(params)
expected_params.insert(0, f"token:{secret}")
# call function and assert result
resp = client.call(client.ADD_URI, params, insert_secret=True)
assert resp == expected_params
@mock_responses.activate
def test_format_inline_images_without_content_type(self):
self.givenTestImage(content_type='')
input_email = {'body': '<div><img src="http://test-url.png"></div>'}
output_email = email_parser.format_inline_images(input_email, self.fail_if_called)
self.assertStartsWith(output_email['body'], '<div></div>
@mock_responses.activate
def test_with_missing_team(self):
mock_responses.add(
mock_responses.POST,
github.GRAPHQL_URL,
body='''{
"data": {
"viewer": {
"login": "user",
"organization": {
"teams": {
"edges": [
{"cursor": "cursor1"}
],
"nodes": [
{"slug": "team1"}
]
@mock_responses.activate
def test_makes_request_when_key_is_set(self):
mock_responses.add(mock_responses.DELETE, 'https://api.sendgrid.com/v3/user/webhooks/parse/settings/my-domain')
action = DeleteSendgridMailbox('my-key')
action('my-client-id', 'my-domain')
self.assertEqual(len(mock_responses.calls), 1)
@mock_responses.activate
def test_format_inline_images_with_img_tag(self):
self.givenTestImage()
input_email = {'body': '<div><h3>test image</h3><img src="http://test-url.png"></div>'}
output_email = email_parser.format_inline_images(input_email, self.fail_if_called)
self.assertStartsWith(output_email['body'], '<div><h3>test image</h3></div>
@mock.activate
def test_parse_date_types(self, patched_server_info):
mock.add(
mock.POST, self.url, status=200,
body=(
'a\n' +
'Date\n' +
'2012-10-25\n'
)
)
table = Table(
't1', self.metadata(),
Column('a', types.Date)
)
rv = self.session.query(*table.c).first()
@mock_responses.activate
def test_format_inline_images_with_query_string(self):
url = 'http://test-url.png?foo=bar&baz=qux'
self.givenTestImage(url=url, content_type='')
input_email = {'body': f'<div><h3>test image</h3><img src="{url}"></div>'}
output_email = email_parser.format_inline_images(input_email, self.fail_if_called)
self.assertStartsWith(output_email['body'], '<div><h3>test image</h3></div>
@mock.activate
def test_parse_nullable_type(self):
mock.add(
mock.POST, self.url, status=200,
body=(
'a\n' +
'String\n' +
'\\N\n' +
'\\\\N\n' +
'\n'
)
)
table = Table(
't1', self.metadata(),
Column('a', types.String)
)