Skip to content

Commit

Permalink
Fix unstable test.
Browse files Browse the repository at this point in the history
  • Loading branch information
onrik committed Jan 4, 2017
1 parent fc7dd07 commit cad3938
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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(
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit cad3938

Please sign in to comment.