def _assert_requests_equal(actual, expected): assert_equal(actual['body'], expected.get('body', '').encode('utf-8'), 'Body value') actual_headers = HeadersDict(actual['headers']) expected_headers = HeadersDict(expected.get('headers', {})) excluded_headers = expected.get('forbidHeaders', []) _assert_expected_headers_in_request( actual_headers, expected_headers, excluded_headers ) assert_equal(actual['url_path'], expected.get('uri', ''), "URI") if 'method' in expected: assert_equal(actual['method'], expected['method'], "Method")
class TestHeadersDict(unittest.TestCase): def setUp(self): self.headers = HeadersDict() def test_get_insensitive(self): self.headers['foo'] = 'bar' self.assertEqual(self.headers['FOO'], 'bar') def test_set_insensitive(self): self.headers['foo'] = 'bar' self.headers['FOO'] = 'baz' self.assertEqual(self.headers['foo'], 'baz') def test_del_insensitive(self): self.headers['foo'] = 'bar' self.assertEqual(self.headers['FOO'], 'bar') del self.headers['FoO'] with self.assertRaises(KeyError): self.headers['foo'] def test_iteration(self): self.headers['FOO'] = 'bar' self.headers['dead'] = 'beef' self.assertIn('FOO', list(self.headers)) self.assertIn('dead', list(self.headers)) headers_items = list(self.headers.items()) self.assertIn(('FOO', 'bar'), headers_items) self.assertIn(('dead', 'beef'), headers_items)
def setUp(self): self.headers = HeadersDict()
def setUp(self): self.response = AWSResponse('http://url.com', 200, HeadersDict(), None) self.response.raw = Mock()