Total Complexity | 10 |
Total Lines | 24 |
Duplicated Lines | 0 % |
1 | import sys |
||
10 | class TestClient(unittest.TestCase): |
||
11 | def test_pair_code_check(self): |
||
12 | """tests whether the pairing code is syntatically correct""" |
||
13 | new_client = Client() |
||
14 | with self.assertRaisesRegexp(BitPayArgumentError, "pairing code is not legal"): |
||
15 | new_client.pair_pos_client("abcd") |
||
16 | |||
17 | def test_passes_errors_when_pairing(self): |
||
18 | """web errors should be gracefully passed to the client""" |
||
19 | new_client = Client() |
||
20 | def a_request(url, request): |
||
21 | return {'status_code': 403, 'content': b'{"error": "this is a 403 error"}'} |
||
22 | with HTTMock(a_request): |
||
23 | with self.assertRaisesRegexp(BitPayBitPayError, "403: this is a 403 error"): |
||
24 | new_client.pair_pos_client("a1B2c3d") |
||
25 | |||
26 | def test_passes_errors_when_creating_invoice(self): |
||
27 | """web errors should be gracefully passed to the client""" |
||
28 | new_client = Client() |
||
29 | def a_request(url, request): |
||
30 | return {'status_code': 403, 'content': b'{"error": "this is a 403 error"}'} |
||
31 | with HTTMock(a_request): |
||
32 | with self.assertRaisesRegexp(BitPayBitPayError, "403: this is a 403 error"): |
||
33 | new_client.create_invoice({"price": 20, "currency": "USD"}) |
||
34 | |||
36 |