test_latest.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:fixerio 作者: amatellanes 项目源码 文件源码
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'')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号