re-add changes
This commit is contained in:
Родитель
36f935847b
Коммит
f80f71deca
|
@ -1,11 +1,11 @@
|
||||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
# Licensed under the MIT License
|
# Licensed under the MIT License
|
||||||
# import filecmp
|
import filecmp
|
||||||
import os
|
import os
|
||||||
# import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import typing
|
import typing
|
||||||
# import base64
|
import base64
|
||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
@ -128,31 +128,31 @@ class ThirdPartyHttpFunctionsTestBase:
|
||||||
# System logs stderr should not exist in host_out
|
# System logs stderr should not exist in host_out
|
||||||
self.assertNotIn('Secret42', host_out)
|
self.assertNotIn('Secret42', host_out)
|
||||||
|
|
||||||
# def test_raw_body_bytes(self):
|
def test_raw_body_bytes(self):
|
||||||
# parent_dir = pathlib.Path(__file__).parent.parent
|
parent_dir = pathlib.Path(__file__).parent.parent
|
||||||
# image_file = parent_dir / 'unittests/resources/functions.png'
|
image_file = parent_dir / 'unittests/resources/functions.png'
|
||||||
# with open(image_file, 'rb') as image:
|
with open(image_file, 'rb') as image:
|
||||||
# img = image.read()
|
img = image.read()
|
||||||
# encoded_image = base64.b64encode(img).decode('utf-8')
|
encoded_image = base64.b64encode(img).decode('utf-8')
|
||||||
# html_img_tag = \
|
html_img_tag = \
|
||||||
# f'<img src="data:image/png;base64,{encoded_image}" alt="PNG Image"/>' # noqa
|
f'<img src="data:image/png;base64,{encoded_image}" alt="PNG Image"/>' # noqa
|
||||||
# sanitized_img_len = len(html_img_tag)
|
sanitized_img_len = len(html_img_tag)
|
||||||
# r = self.webhost.request('POST', 'raw_body_bytes', data=img,
|
r = self.webhost.request('POST', 'raw_body_bytes', data=img,
|
||||||
# no_prefix=True)
|
no_prefix=True)
|
||||||
#
|
|
||||||
# received_body_len = int(r.headers['body-len'])
|
received_body_len = int(r.headers['body-len'])
|
||||||
# self.assertEqual(received_body_len, sanitized_img_len)
|
self.assertEqual(received_body_len, sanitized_img_len)
|
||||||
#
|
|
||||||
# encoded_image_data = encoded_image.split(",")[0]
|
encoded_image_data = encoded_image.split(",")[0]
|
||||||
# body = base64.b64decode(encoded_image_data)
|
body = base64.b64decode(encoded_image_data)
|
||||||
# try:
|
try:
|
||||||
# received_img_file = parent_dir / 'received_img.png'
|
received_img_file = parent_dir / 'received_img.png'
|
||||||
# with open(received_img_file, 'wb') as received_img:
|
with open(received_img_file, 'wb') as received_img:
|
||||||
# received_img.write(body)
|
received_img.write(body)
|
||||||
# self.assertTrue(filecmp.cmp(received_img_file, image_file))
|
self.assertTrue(filecmp.cmp(received_img_file, image_file))
|
||||||
# finally:
|
finally:
|
||||||
# if (os.path.exists(received_img_file)):
|
if (os.path.exists(received_img_file)):
|
||||||
# os.remove(received_img_file)
|
os.remove(received_img_file)
|
||||||
|
|
||||||
def test_return_http_no_body(self):
|
def test_return_http_no_body(self):
|
||||||
r = self.webhost.request('GET', 'return_http_no_body',
|
r = self.webhost.request('GET', 'return_http_no_body',
|
||||||
|
@ -160,15 +160,15 @@ class ThirdPartyHttpFunctionsTestBase:
|
||||||
self.assertEqual(r.text, '')
|
self.assertEqual(r.text, '')
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
|
||||||
# def test_return_http_redirect(self):
|
def test_return_http_redirect(self):
|
||||||
# r = self.webhost.request('GET', 'return_http_redirect',
|
r = self.webhost.request('GET', 'return_http_redirect',
|
||||||
# no_prefix=True)
|
no_prefix=True)
|
||||||
# self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
# self.assertEqual(r.text, '<h1>Hello World™</h1>')
|
self.assertEqual(r.text, '<h1>Hello World™</h1>')
|
||||||
#
|
|
||||||
# r = self.webhost.request('GET', 'return_http_redirect',
|
r = self.webhost.request('GET', 'return_http_redirect',
|
||||||
# allow_redirects=False, no_prefix=True)
|
allow_redirects=False, no_prefix=True)
|
||||||
# self.assertEqual(r.status_code, 302)
|
self.assertEqual(r.status_code, 302)
|
||||||
|
|
||||||
def test_unhandled_error(self):
|
def test_unhandled_error(self):
|
||||||
r = self.webhost.request('GET', 'unhandled_error', no_prefix=True)
|
r = self.webhost.request('GET', 'unhandled_error', no_prefix=True)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче