Skip to content

Commit 1a4a7c1

Browse files
authored
[ITT-72] Unit tests for all (checkout) method names (#222)
* test the test * Update method-name-test.yml * Update method-name-test.yml * Update checkoutTest.py * test * Update method-name-test.yml * delete github actions
1 parent 321284e commit 1a4a7c1

File tree

5 files changed

+141
-0
lines changed

5 files changed

+141
-0
lines changed

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ $(services): build/spec
4848
cp build/api/api-single.py Adyen/services/$@/__init__.py
4949
rm -rf build
5050

51+
5152
$(smallServices): build/spec
5253
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar -O build/openapi-generator-cli.jar
5354
rm -rf Adyen/services/$@
@@ -64,6 +65,21 @@ $(smallServices): build/spec
6465
rm -rf build
6566

6667

68+
6769
build/spec:
6870
git clone https://github.com/Adyen/adyen-openapi.git build/spec
6971
perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
72+
73+
74+
generateCheckoutTest: build/spec
75+
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar -O build/openapi-generator-cli.jar
76+
$(openapi-generator-cli) generate \
77+
-i build/spec/json/CheckoutService-v70.json \
78+
-g $(generator) \
79+
-c ./templates/config.yaml \
80+
-o build \
81+
--global-property apis,apiTests=false,supportingFiles=api-test.py\
82+
--additional-properties serviceName=checkout \
83+
--skip-validate-spec
84+
cp build/api/api-test.py test/methodNamesTests/checkoutTest.py
85+
rm -rf build

templates/api-test-single.mustache

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import unittest
2+
from Adyen import {{serviceName}}
3+
4+
5+
{{#apiInfo}}
6+
{{#apis}}
7+
class Test{{classname}}(unittest.TestCase):
8+
client = {{serviceName}}.{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}
9+
{{> api-test }}
10+
11+
{{/apis}}
12+
{{/apiInfo}}

templates/api-test.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{#operations}}{{#operation}}
2+
def test_{{#lambda.snakecase}}{{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}{{/lambda.snakecase}}(self):
3+
self.assertIsNotNone(self.client.{{#lambda.snakecase}}{{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}{{/lambda.snakecase}})
4+
{{/operation}}
5+
{{/operations}}

templates/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ files:
77
api-small.mustache:
88
destinationFilename: -small.py
99
templateType: API
10+
api-test-single.mustache:
11+
folder: api
12+
destinationFilename: api-test.py
13+
templateType: SupportingFiles
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import unittest
2+
from Adyen import checkout
3+
4+
5+
class TestClassicCheckoutSDKApi(unittest.TestCase):
6+
client = checkout.classic_checkout_sdk_api
7+
8+
def test_payment_session(self):
9+
self.assertIsNotNone(self.client.payment_session)
10+
11+
def test_verify_payment_result(self):
12+
self.assertIsNotNone(self.client.verify_payment_result)
13+
14+
15+
class TestModificationsApi(unittest.TestCase):
16+
client = checkout.modifications_api
17+
18+
def test_cancel_authorised_payment(self):
19+
self.assertIsNotNone(self.client.cancel_authorised_payment)
20+
21+
def test_update_authorised_amount(self):
22+
self.assertIsNotNone(self.client.update_authorised_amount)
23+
24+
def test_cancel_authorised_payment_by_psp_reference(self):
25+
self.assertIsNotNone(self.client.cancel_authorised_payment_by_psp_reference)
26+
27+
def test_capture_authorised_payment(self):
28+
self.assertIsNotNone(self.client.capture_authorised_payment)
29+
30+
def test_refund_captured_payment(self):
31+
self.assertIsNotNone(self.client.refund_captured_payment)
32+
33+
def test_refund_or_cancel_payment(self):
34+
self.assertIsNotNone(self.client.refund_or_cancel_payment)
35+
36+
37+
class TestOrdersApi(unittest.TestCase):
38+
client = checkout.orders_api
39+
40+
def test_orders(self):
41+
self.assertIsNotNone(self.client.orders)
42+
43+
def test_cancel_order(self):
44+
self.assertIsNotNone(self.client.cancel_order)
45+
46+
def test_get_balance_of_gift_card(self):
47+
self.assertIsNotNone(self.client.get_balance_of_gift_card)
48+
49+
50+
class TestPaymentLinksApi(unittest.TestCase):
51+
client = checkout.payment_links_api
52+
53+
def test_get_payment_link(self):
54+
self.assertIsNotNone(self.client.get_payment_link)
55+
56+
def test_update_payment_link(self):
57+
self.assertIsNotNone(self.client.update_payment_link)
58+
59+
def test_payment_links(self):
60+
self.assertIsNotNone(self.client.payment_links)
61+
62+
63+
class TestPaymentsApi(unittest.TestCase):
64+
client = checkout.payments_api
65+
66+
def test_card_details(self):
67+
self.assertIsNotNone(self.client.card_details)
68+
69+
def test_donations(self):
70+
self.assertIsNotNone(self.client.donations)
71+
72+
def test_payment_methods(self):
73+
self.assertIsNotNone(self.client.payment_methods)
74+
75+
def test_payments(self):
76+
self.assertIsNotNone(self.client.payments)
77+
78+
def test_payments_details(self):
79+
self.assertIsNotNone(self.client.payments_details)
80+
81+
def test_sessions(self):
82+
self.assertIsNotNone(self.client.sessions)
83+
84+
85+
class TestRecurringApi(unittest.TestCase):
86+
client = checkout.recurring_api
87+
88+
def test_delete_token_for_stored_payment_details(self):
89+
self.assertIsNotNone(self.client.delete_token_for_stored_payment_details)
90+
91+
def test_get_tokens_for_stored_payment_details(self):
92+
self.assertIsNotNone(self.client.get_tokens_for_stored_payment_details)
93+
94+
95+
class TestUtilityApi(unittest.TestCase):
96+
client = checkout.utility_api
97+
98+
def test_get_apple_pay_session(self):
99+
self.assertIsNotNone(self.client.get_apple_pay_session)
100+
101+
def test_origin_keys(self):
102+
self.assertIsNotNone(self.client.origin_keys)
103+
104+

0 commit comments

Comments
 (0)