File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import pytest
2+ from baddns .lib .httpmanager import headers_to_dict
3+ from baddns .mock_blasthttp import MockBlastHTTP
4+
5+
6+ def test_headers_to_dict_passes_through_dict ():
7+ headers = {"content-type" : "text/html" , "x-foo" : "bar" }
8+ assert headers_to_dict (headers ) is headers
9+
10+
11+ @pytest .mark .asyncio
12+ async def test_mock_blasthttp_pops_queued_responses_in_order ():
13+ mock = MockBlastHTTP ()
14+ mock .add_response (url = "http://example.com/" , status = 200 , body = "first" )
15+ mock .add_response (url = "http://example.com/" , status = 500 , body = "second" )
16+
17+ first = await mock .request ("http://example.com/" )
18+ second = await mock .request ("http://example.com/" )
19+ third = await mock .request ("http://example.com/" )
20+
21+ assert first .status == 200 and first .body == "first"
22+ assert second .status == 500 and second .body == "second"
23+ # one response left in queue — len(queue) == 1 path returns it without popping
24+ assert third is second
You can’t perform that action at this time.
0 commit comments