|
1 | | -import moyasar |
2 | | -import tests.server_stubs as ss |
3 | | -import tests.fixtures.fixtures as f |
4 | 1 | import copy |
5 | | -import pytest |
6 | | - |
7 | | - |
8 | | -def test_create_should_return_intiated_payment_for_sadad_source(): |
9 | | - params = {"amount": 1000, "currency": "SAR", "description": "Test"} |
10 | | - ss.stub_server_request("post", moyasar.Payment.create_url(), |
11 | | - resource=f.payment, status=200) |
12 | | - moyasar.api_key = 'sk_test_BQokikJOvBiI2HlWgH4olfQ2' |
13 | | - payment = moyasar.Payment.create(params) |
14 | | - assert isinstance(payment, moyasar.Payment) |
15 | | - assert payment.status == "initiated" |
16 | | - assert int(payment.amount) == params['amount'] |
17 | | - assert payment.currency == params['currency'] |
18 | | - assert payment.description == params['description'] |
19 | | - |
20 | | - |
21 | | -def test_create_with_amount_less_than_100_cent_should_raise_validation_errror(): |
22 | | - modified_resource = copy.deepcopy(f.payment) |
23 | | - modified_resource.update({"amount": 90}) |
24 | | - ss.stub_server_request('post', moyasar.Payment.create_url(), resource=modified_resource, |
25 | | - status=400, error_message="Validation Failed", |
26 | | - errors={"amount": "must be greater than 99"}) |
27 | | - assert pytest.raises(Exception) |
28 | | - |
29 | | - |
30 | | -def test_create_payment_for_inovice_should_be_acceptable(): |
31 | | - ss.stub_server_request("get", moyasar.Invoice.list_url(), |
32 | | - resource=f.invoices, status=200) |
33 | | - invoices = moyasar.Invoice.list() |
34 | | - first_invoice_id = '' |
35 | | - for key, val in invoices[0].__dict__.items(): |
36 | | - if key == "id": |
37 | | - first_invoice_id = val |
38 | 2 |
|
39 | | - modified_resource = copy.deepcopy(f.payment) |
40 | | - modified_resource.update({"invoice_id": first_invoice_id}) |
41 | | - ss.stub_server_request("post", moyasar.Payment.create_url(), |
42 | | - resource=modified_resource, status=200) |
43 | | - moyasar.api_key = 'sk_test_BQokikJOvBiI2HlWgH4olfQ2' |
44 | | - payment = moyasar.Payment.create(modified_resource) |
45 | | - assert isinstance(payment, moyasar.Payment) |
46 | | - assert payment.invoice_id == first_invoice_id |
| 3 | +import moyasar |
| 4 | +import tests.fixtures.fixtures as f |
| 5 | +import tests.server_stubs as ss |
47 | 6 |
|
48 | 7 |
|
49 | 8 | def test_list_should_return_list_of_payment_objects(): |
@@ -87,29 +46,6 @@ def test_update_should_update_payment_description(): |
87 | 46 | assert new_description["description"] == after_updated.description |
88 | 47 |
|
89 | 48 |
|
90 | | -# def test_refund_should_operate_normally_by_recharging_back_all_amount_as_a_default(): |
91 | | -# id = '328f5dca-91ec-435d-b13f-86052a1d0f7b' |
92 | | -# ss.stub_server_request("get", moyasar.Payment.fetch_url(id), |
93 | | -# resource=f.payment, status=200) |
94 | | -# moyasar.api_key = 'sk_test_BQokikJOvBiI2HlWgH4olfQ2' |
95 | | -# original = moyasar.Payment.fetch(id) |
96 | | -# params = {'status': 'refunded', 'refunded': original.amount} |
97 | | -# custom_invoice = copy.deepcopy(f.payment) |
98 | | -# custom_invoice.update(params) |
99 | | -# ss.stub_server_request("post", f'{moyasar.api_url}/payments/{id}/refund', |
100 | | -# resource=custom_invoice, status=200) |
101 | | -# moyasar.api_key = 'sk_test_BQokikJOvBiI2HlWgH4olfQ2' |
102 | | -# refunded = original.refund(amount=original.amount) |
103 | | - |
104 | | - |
105 | | -def test_refund_should_accept_partial_refund_amounts(): |
106 | | - pass |
107 | | - |
108 | | - |
109 | | -def test_refund_with_failed_payment_should_raise_invalid_request_error(): |
110 | | - pass |
111 | | - |
112 | | - |
113 | 49 | def test_eqaulity_check_holds_among_identical_payments_only(): |
114 | 50 | id = '1b82356d-b5fd-46f8-bde9-3680d62f289a' |
115 | 51 | ss.stub_server_request("get", moyasar.Payment.fetch_url(id), |
|
0 commit comments