Skip to content

Commit 43e291e

Browse files
authored
Merge pull request #35 from voucherifyio/aw/YWxp9cWJ/fix-tests
Fix tests
2 parents 7d8deb4 + 514190c commit 43e291e

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

tests/test_distributions_e2e.py

+6-21
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,14 @@
55
client_secret_key="3266b9f8-e246-4f79-bdf0-833929b1380c"
66
)
77

8-
tracking_id = 'PythonTestUser'
9-
testVoucher = {
10-
"code": "PythonVoucherTest",
11-
"discount": {
12-
"type": "AMOUNT",
13-
"amount_off": 12436
14-
},
15-
"category": "PythonTestCategory",
16-
"start_date": "2016-01-01T00:00:00Z",
17-
"expiration_date": None,
18-
"redemption": {
19-
"quantity": None,
20-
"redeemed_quantity": 0
21-
},
22-
"active": True
23-
}
24-
25-
268
def test_publishVoucher():
279
params = {
2810
"channel": "Email",
29-
"customer": "[email protected]"
11+
"customer": {
12+
"source_id": "[email protected]"
13+
},
14+
"campaign": "Predefined Gift Cards"
3015
}
3116
result = voucherify.distributions.publish(params)
32-
assert result.get('active') is True
33-
assert result.get('type') == 'DISCOUNT_VOUCHER'
17+
assert result.get('voucher').get('active') is True
18+
assert result.get('voucher').get('type') == 'GIFT_VOUCHER'

tests/test_redemptions_e2e.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from voucherify import Client as voucherifyClient
2+
import time
23

34
voucherify = voucherifyClient(
45
application_id="c70a6f00-cf91-4756-9df5-47628850002b",
@@ -44,8 +45,7 @@ def test_redeemVoucherWithCustomerInfo(voucherifyInstance=voucherify.redemptions
4445
"description": "",
4546
"metadata": {
4647
"locale": "en-GB",
47-
"shoeSize": 5,
48-
"favourite_brands": ["Armani", "L'Autre Chose", "Vicini"]
48+
"shoeSize": 5
4949
}
5050
}
5151
payload = {
@@ -67,7 +67,7 @@ def test_getVoucherRedemption(testedMethod=voucherify.redemptions.getForVoucher)
6767
def test_listVoucherRedemptions(testedMethod=voucherify.redemptions.list):
6868
filter_params = {
6969
"limit": 1,
70-
"page": 0,
70+
"page": 1,
7171
"[created_at][before]": "2016-12-31T23:59:59Z",
7272
"[created_at][after]": "2015-01-01T00:00:00Z",
7373
"result": "SUCCESS"
@@ -80,6 +80,8 @@ def test_voucherRedemptionRollback(voucherifyInstance=voucherify.redemptions):
8080
redemption = voucherifyInstance.redeem(testVoucher.get('code'))
8181
redemptionId = redemption.get('id')
8282
reason = 'just testing'
83+
84+
time.sleep(1)
8385
rollbackResult = voucherifyInstance.rollback(redemptionId, reason)
8486
assert rollbackResult.get('result') == 'SUCCESS'
8587
assert rollbackResult.get('reason') == reason

tests/test_vouchers_e2e.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def test_listVouchersFromCategory(voucherifyInstance=voucherify.vouchers):
4747
"category": "PythonTestCategory"
4848
}
4949
vouchers = voucherifyInstance.list(filter_params)
50-
assert len(vouchers) == 1
51-
voucher = vouchers[0]
50+
assert len(vouchers.get('vouchers')) == 1
51+
voucher = vouchers.get('vouchers')[0]
5252
assert voucher.get('code') == testVoucher.get('code')
5353

5454

0 commit comments

Comments
 (0)