From 514190cf082e5bb9ab3bb3388591f91db3423d16 Mon Sep 17 00:00:00 2001 From: awilczek Date: Thu, 18 Jul 2019 17:04:12 +0200 Subject: [PATCH] Fix tests --- tests/test_distributions_e2e.py | 27 ++++++--------------------- tests/test_redemptions_e2e.py | 8 +++++--- tests/test_vouchers_e2e.py | 4 ++-- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/tests/test_distributions_e2e.py b/tests/test_distributions_e2e.py index 11c9071b..d21d6ebd 100644 --- a/tests/test_distributions_e2e.py +++ b/tests/test_distributions_e2e.py @@ -5,29 +5,14 @@ client_secret_key="3266b9f8-e246-4f79-bdf0-833929b1380c" ) -tracking_id = 'PythonTestUser' -testVoucher = { - "code": "PythonVoucherTest", - "discount": { - "type": "AMOUNT", - "amount_off": 12436 - }, - "category": "PythonTestCategory", - "start_date": "2016-01-01T00:00:00Z", - "expiration_date": None, - "redemption": { - "quantity": None, - "redeemed_quantity": 0 - }, - "active": True -} - - def test_publishVoucher(): params = { "channel": "Email", - "customer": "donny.roll@mail.com" + "customer": { + "source_id": "donny.roll@mail.com" + }, + "campaign": "Predefined Gift Cards" } result = voucherify.distributions.publish(params) - assert result.get('active') is True - assert result.get('type') == 'DISCOUNT_VOUCHER' + assert result.get('voucher').get('active') is True + assert result.get('voucher').get('type') == 'GIFT_VOUCHER' diff --git a/tests/test_redemptions_e2e.py b/tests/test_redemptions_e2e.py index edd67971..7e56b6e7 100644 --- a/tests/test_redemptions_e2e.py +++ b/tests/test_redemptions_e2e.py @@ -1,4 +1,5 @@ from voucherify import Client as voucherifyClient +import time voucherify = voucherifyClient( application_id="c70a6f00-cf91-4756-9df5-47628850002b", @@ -44,8 +45,7 @@ def test_redeemVoucherWithCustomerInfo(voucherifyInstance=voucherify.redemptions "description": "", "metadata": { "locale": "en-GB", - "shoeSize": 5, - "favourite_brands": ["Armani", "L'Autre Chose", "Vicini"] + "shoeSize": 5 } } payload = { @@ -67,7 +67,7 @@ def test_getVoucherRedemption(testedMethod=voucherify.redemptions.getForVoucher) def test_listVoucherRedemptions(testedMethod=voucherify.redemptions.list): filter_params = { "limit": 1, - "page": 0, + "page": 1, "[created_at][before]": "2016-12-31T23:59:59Z", "[created_at][after]": "2015-01-01T00:00:00Z", "result": "SUCCESS" @@ -80,6 +80,8 @@ def test_voucherRedemptionRollback(voucherifyInstance=voucherify.redemptions): redemption = voucherifyInstance.redeem(testVoucher.get('code')) redemptionId = redemption.get('id') reason = 'just testing' + + time.sleep(1) rollbackResult = voucherifyInstance.rollback(redemptionId, reason) assert rollbackResult.get('result') == 'SUCCESS' assert rollbackResult.get('reason') == reason diff --git a/tests/test_vouchers_e2e.py b/tests/test_vouchers_e2e.py index d8f5a461..2066d331 100644 --- a/tests/test_vouchers_e2e.py +++ b/tests/test_vouchers_e2e.py @@ -47,8 +47,8 @@ def test_listVouchersFromCategory(voucherifyInstance=voucherify.vouchers): "category": "PythonTestCategory" } vouchers = voucherifyInstance.list(filter_params) - assert len(vouchers) == 1 - voucher = vouchers[0] + assert len(vouchers.get('vouchers')) == 1 + voucher = vouchers.get('vouchers')[0] assert voucher.get('code') == testVoucher.get('code')