def test_proxy_reponse_post(mock_search): mock_search.return_value = index.proxy_reponse('{}') index.proxy_request({ 'body': '<SEARCH_XML>', 'httpMethod': 'POST', 'path': '/simple/', }) mock_search.assert_called_once_with('<SEARCH_XML>')
def test_proxy_reponse(): ret = index.proxy_reponse('FIZZ') exp = { 'body': 'FIZZ', 'headers': {'Content-Type': 'text/html; charset=UTF-8'}, 'statusCode': 200, } assert ret == exp
def test_proxy_reponse(): body = 'FIZZ' ret = index.proxy_reponse('FIZZ') exp = { 'body': body, 'statusCode': 200, 'headers': { 'content-length': len(body), 'content-type': 'text/html; charset=utf-8', }, } assert ret == exp
def test_handler_package(mock_idx): mock_idx.return_value = index.proxy_reponse(PACKAGE_INDEX) index.handler({'path': '/simple/fizz/'}) mock_idx.assert_called_once_with('fizz')
def test_handler_simple(mock_idx): mock_idx.return_value = index.proxy_reponse(SIMPLE_INDEX) index.handler({'path': '/simple/'}) mock_idx.assert_called_once_with()
def test_proxy_request_get_package(event): with mock.patch('index.get_package_index') as mock_pkg: mock_pkg.return_value = index.proxy_reponse(PACKAGE_INDEX) index.proxy_request(event) mock_pkg.assert_called_once_with('fizz')
def test_proxy_reponse_post(event): with mock.patch('index.search') as mock_search: mock_search.return_value = index.proxy_reponse('{}') index.proxy_request(event) mock_search.assert_called_once_with('<SEARCH_XML>')
def test_proxy_request_get(event): with mock.patch('index.get_index') as mock_idx: mock_idx.return_value = index.proxy_reponse(SIMPLE_INDEX) index.proxy_request(event) mock_idx.assert_called_once_with()
def test_proxy_request_get_package(mock_pkg): mock_pkg.return_value = index.proxy_reponse(PACKAGE_INDEX) index.proxy_request({'httpMethod': 'GET', 'path': '/simple/fizz/'}) mock_pkg.assert_called_once_with('fizz')
def test_proxy_request_get(mock_idx): mock_idx.return_value = index.proxy_reponse(SIMPLE_INDEX) index.proxy_request({'httpMethod': 'GET', 'path': '/simple/'}) mock_idx.assert_called_once_with()