From cad39389cc4d165c461d770beb688a88c797b1b8 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 4 Jan 2017 14:51:18 +0300 Subject: [PATCH] Fix unstable test. --- tests/test_client.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 1670f22..4e91758 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -27,6 +27,11 @@ def setUp(self): def tearDown(self): httpretty.reset() + def parse(self, data): + if isinstance(data, bytes): + data = data.decode('utf-8') + return dict(map(lambda x: x.split('='), data.split('&'))) + def test__get_invoice_url(self): self.assertEqual( self.client._get_invoice_url('10001'), @@ -46,7 +51,10 @@ def test_url_encode(self): 'user': 'tel:+79998887766', }) - self.assertEqual(encoded, 'foo=bar&user=tel%3A%2B79998887766') + self.assertEqual(self.parse(encoded), { + 'foo': 'bar', + 'user': 'tel%3A%2B79998887766', + }) def test_make_auth(self): self.assertEqual( @@ -122,12 +130,12 @@ def test_create_invoice(self): ) self.assertEqual(invoice, {'invoice_id': '101'}) - self.assertEqual(httpretty.HTTPretty.last_request.parsed_body, { - 'amount': ['22.00'], - 'ccy': ['RUB'], - 'comment': ['Order #101'], - 'user': ['tel: 79998887766'], - 'lifetime': ['2017-01-02T15:22:33'] + self.assertEqual(self.parse(httpretty.HTTPretty.last_request.body), { + 'amount': '22.00', + 'ccy': 'RUB', + 'comment': 'Order+%23101', + 'user': 'tel%3A%2B79998887766', + 'lifetime': '2017-01-02T15%3A22%3A33', }) def test_cancel_invoice(self):