def test_returns_latest_rates_for_symbols_passed_in_method_if_both(self):
symbols = ['USD', 'GBP']
other_symbols = ['JPY', 'EUR']
expected_response = {
"base": "EUR",
"date": "2016-05-19",
"rates": {"GBP": 0.76585, "USD": 1.1197}
}
httpretty.register_uri(httpretty.GET,
self.url,
body=json.dumps(expected_response),
content_type='application/json')
client = Fixerio(symbols=other_symbols)
response = client.latest(symbols=symbols)
self.assertDictEqual(response, expected_response)
request = httpretty.last_request()
self.assertEqual(request.method, 'GET')
symbols_str = ','.join(symbols)
params = urlencode({'symbols': symbols_str})
expected_path = '{url}?{params}'.format(url=self.path, params=params)
self.assertEqual(request.path, expected_path)
self.assertEqual(request.querystring, {'symbols': [symbols_str]})
self.assertEqual(request.body, b'')
评论列表
文章目录