|
10 | 10 | from tornado.testing import AsyncHTTPTestCase, bind_unused_port |
11 | 11 | from unittest.mock import patch |
12 | 12 | import web_monitoring_diff.server.server as df |
| 13 | +from web_monitoring_diff.server.mock_http import MockResponse |
13 | 14 | from web_monitoring_diff.exceptions import UndecodableContentError |
14 | 15 | import web_monitoring_diff |
15 | 16 | from tornado.escape import utf8 |
@@ -234,7 +235,7 @@ async def responder(handler): |
234 | 235 | assert response.code == 504 |
235 | 236 |
|
236 | 237 | def test_missing_params_caller_func(self): |
237 | | - response = df.MockResponse('http://example.org/', 'Whatever') |
| 238 | + response = MockResponse('http://example.org/', 'Whatever') |
238 | 239 | with self.assertRaises(KeyError): |
239 | 240 | df.caller(mock_diffing_method, response, response) |
240 | 241 |
|
@@ -603,7 +604,7 @@ def mock_tornado_request(fixture, headers=None): |
603 | 604 | path = fixture_path(fixture) |
604 | 605 | with open(path, 'rb') as f: |
605 | 606 | body = f.read() |
606 | | - return df.MockResponse(f'file://{path}', body, headers) |
| 607 | + return MockResponse(f'file://{path}', body, headers) |
607 | 608 |
|
608 | 609 |
|
609 | 610 | # TODO: we may want to extract this to a support module |
@@ -680,23 +681,23 @@ def _find_stub(self, request): |
680 | 681 |
|
681 | 682 | class MockResponderHeadersTest(unittest.TestCase): |
682 | 683 | def test_pdf_extension(self): |
683 | | - response = df.MockResponse(f'file://{fixture_path("simple.pdf")}', '') |
| 684 | + response = MockResponse(f'file://{fixture_path("simple.pdf")}', '') |
684 | 685 | assert response.headers['Content-Type'] == 'application/pdf' |
685 | 686 |
|
686 | 687 | def test_html_extension(self): |
687 | | - response = df.MockResponse(f'file://{fixture_path("unknown_encoding.html")}', '') |
| 688 | + response = MockResponse(f'file://{fixture_path("unknown_encoding.html")}', '') |
688 | 689 | assert response.headers['Content-Type'] == 'text/html' |
689 | 690 |
|
690 | 691 | def test_txt_extension(self): |
691 | | - response = df.MockResponse(f'file://{fixture_path("empty.txt")}', '') |
| 692 | + response = MockResponse(f'file://{fixture_path("empty.txt")}', '') |
692 | 693 | assert response.headers['Content-Type'] == 'text/plain' |
693 | 694 |
|
694 | 695 | def test_no_extension_should_assume_html(self): |
695 | | - response = df.MockResponse(f'file://{fixture_path("unknown_encoding")}', '') |
| 696 | + response = MockResponse(f'file://{fixture_path("unknown_encoding")}', '') |
696 | 697 | assert response.headers['Content-Type'] == 'text/html' |
697 | 698 |
|
698 | 699 | def test_unknown_extension_should_assume_html(self): |
699 | | - response = df.MockResponse(f'file://{fixture_path("unknown_encoding.notarealextension")}', '') |
| 700 | + response = MockResponse(f'file://{fixture_path("unknown_encoding.notarealextension")}', '') |
700 | 701 | assert response.headers['Content-Type'] == 'text/html' |
701 | 702 |
|
702 | 703 |
|
|
0 commit comments