From f5e94d786152a55a73482d1c8a7044cf172e3818 Mon Sep 17 00:00:00 2001 From: Marc Galofre Date: Tue, 7 Mar 2017 09:17:08 +0100 Subject: [PATCH] litlle refactor tests --- addonpayments/hpp/tests/conftest.py | 40 ++- .../hpp/tests/tests/test_generation_utils.py | 6 +- .../hpp/tests/tests/test_json_utils.py | 274 +++++++++--------- addonpayments/hpp/tests/utils.py | 2 +- tox.ini | 8 +- 5 files changed, 167 insertions(+), 163 deletions(-) diff --git a/addonpayments/hpp/tests/conftest.py b/addonpayments/hpp/tests/conftest.py index 5526e9d..88e336d 100644 --- a/addonpayments/hpp/tests/conftest.py +++ b/addonpayments/hpp/tests/conftest.py @@ -7,17 +7,9 @@ from addonpayments.hpp.card_storage.requests import CardStorageRequest from addonpayments.hpp.payment.requests import PaymentRequest -from addonpayments.hpp.tests.utils import sample_path, only_mandatory_hpp_request, hpp_request_storage_enabled +from addonpayments.hpp.tests.utils import get_sample_path, only_mandatory_hpp_request, hpp_request_storage_enabled from addonpayments.hpp.utils import JsonUtils -CHARSET = "utf-8" -HPP_PAYMENT_REQUEST_VALID_JSON_PATH = "samples/hpp_payment_request.json" -HPP_PAYMENT_REQUEST_SUPPLEMENTARY_JSON_PATH = "samples/hpp_payment_request_supplementary_data.json" -HPP_PAYMENT_REQUEST_ENCODED_JSON_PATH = "samples/hpp_payment_request_encoded.json" -HPP_CARD_STORAGE_REQUEST_VALID_JSON_PATH = "samples/hpp_card_storage_request.json" -HPP_CARD_STORAGE_REQUEST_SUPPLEMENTARY_JSON_PATH = "samples/hpp_card_storage_request_supplementary_data.json" -HPP_CARD_STORAGE_REQUEST_ENCODED_JSON_PATH = "samples/hpp_card_storage_request_encoded.json" - @pytest.fixture() def valid_hpp_request(): @@ -33,35 +25,41 @@ def valid_hpp_request_storage_enabled(): @pytest.fixture() def json_hpp_payment_request_valid(): - with codecs.open(sample_path(HPP_PAYMENT_REQUEST_VALID_JSON_PATH), 'r', encoding='utf-8') as data_file: - yield JsonUtils.from_json_hpp_request(data_file.read(), CHARSET, False) + path = get_sample_path('samples/hpp_payment_request.json') + with codecs.open(path, 'r', encoding='utf-8') as data_file: + yield JsonUtils.from_json_hpp_request(data_file.read(), 'utf-8', False) @pytest.fixture() def json_hpp_payment_request_supplementary_data(): - with codecs.open(sample_path(HPP_PAYMENT_REQUEST_SUPPLEMENTARY_JSON_PATH), 'r', encoding='utf-8') as data_file: - yield JsonUtils.from_json_hpp_request(data_file.read(), CHARSET, False) + path = get_sample_path('samples/hpp_payment_request_supplementary_data.json') + with codecs.open(path, 'r', encoding='utf-8') as data_file: + yield JsonUtils.from_json_hpp_request(data_file.read(), 'utf-8', False) @pytest.fixture() def json_hpp_payment_request_encoded(): - with codecs.open(sample_path(HPP_PAYMENT_REQUEST_ENCODED_JSON_PATH), 'r', encoding='utf-8') as data_file: - yield JsonUtils.from_json_hpp_request(data_file.read(), CHARSET, True) + path = get_sample_path('samples/hpp_payment_request_encoded.json') + with codecs.open(path, 'r', encoding='utf-8') as data_file: + yield JsonUtils.from_json_hpp_request(data_file.read(), 'utf-8', True) @pytest.fixture() def json_hpp_card_storage_request_valid(): - with codecs.open(sample_path(HPP_CARD_STORAGE_REQUEST_VALID_JSON_PATH), 'r', encoding='utf-8') as data_file: - yield JsonUtils.from_json_hpp_request(data_file.read(), CHARSET, False) + path = get_sample_path('samples/hpp_card_storage_request.json') + with codecs.open(path, 'r', encoding='utf-8') as data_file: + yield JsonUtils.from_json_hpp_request(data_file.read(), 'utf-8', False) @pytest.fixture() def json_hpp_card_storage_request_supp_data(): - with codecs.open(sample_path(HPP_CARD_STORAGE_REQUEST_SUPPLEMENTARY_JSON_PATH), 'r', encoding='utf-8') as data_file: - yield JsonUtils.from_json_hpp_request(data_file.read(), CHARSET, False) + path = get_sample_path('samples/hpp_card_storage_request_supplementary_data.json') + with codecs.open(path, 'r', encoding='utf-8') as data_file: + yield JsonUtils.from_json_hpp_request(data_file.read(), 'utf-8', False) @pytest.fixture() def json_hpp_card_storage_request_encoded(): - with codecs.open(sample_path(HPP_CARD_STORAGE_REQUEST_ENCODED_JSON_PATH), 'r', encoding='utf-8') as data_file: - yield JsonUtils.from_json_hpp_request(data_file.read(), CHARSET, True) + path = get_sample_path('samples/hpp_card_storage_request_encoded.json') + with codecs.open(path, 'r', encoding='utf-8') as data_file: + yield JsonUtils.from_json_hpp_request(data_file.read(), 'utf-8', True) diff --git a/addonpayments/hpp/tests/tests/test_generation_utils.py b/addonpayments/hpp/tests/tests/test_generation_utils.py index 5d4c36e..5247c15 100644 --- a/addonpayments/hpp/tests/tests/test_generation_utils.py +++ b/addonpayments/hpp/tests/tests/test_generation_utils.py @@ -12,9 +12,9 @@ def test_generate_hash(self): """ Test Hash generation success case. """ - test_string = "20120926112654.thestore.ORD453-11.00.Successful.3737468273643.79347" - secret = "mysecret" - expected_result = "368df010076481d47a21e777871012b62b976339" + test_string = '20120926112654.thestore.ORD453-11.00.Successful.3737468273643.79347' + secret = 'mysecret' + expected_result = '368df010076481d47a21e777871012b62b976339' result = GenerationUtils.generate_hash(test_string, secret) assert expected_result == result diff --git a/addonpayments/hpp/tests/tests/test_json_utils.py b/addonpayments/hpp/tests/tests/test_json_utils.py index 0547e1c..311f6a2 100644 --- a/addonpayments/hpp/tests/tests/test_json_utils.py +++ b/addonpayments/hpp/tests/tests/test_json_utils.py @@ -16,27 +16,27 @@ def test_from_json_hpp_payment_request(self, json_hpp_payment_request_valid): :param json_hpp_payment_request_valid: PaymentRequest """ assert isinstance(json_hpp_payment_request_valid, PaymentRequest) - assert json_hpp_payment_request_valid.merchant_id == "MerchantID" - assert json_hpp_payment_request_valid.account == "myAccount" - assert json_hpp_payment_request_valid.order_id == "OrderID" - assert json_hpp_payment_request_valid.amount == "100" - assert json_hpp_payment_request_valid.currency == "EUR" - assert json_hpp_payment_request_valid.timestamp == "20990101120000" - assert json_hpp_payment_request_valid.sha1hash == "5d8f05abd618e50db4861a61cc940112786474cf" - assert json_hpp_payment_request_valid.auto_settle_flag == "1" - comment1 = "a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;" \ - "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥" + assert json_hpp_payment_request_valid.merchant_id == 'MerchantID' + assert json_hpp_payment_request_valid.account == 'myAccount' + assert json_hpp_payment_request_valid.order_id == 'OrderID' + assert json_hpp_payment_request_valid.amount == '100' + assert json_hpp_payment_request_valid.currency == 'EUR' + assert json_hpp_payment_request_valid.timestamp == '20990101120000' + assert json_hpp_payment_request_valid.sha1hash == '5d8f05abd618e50db4861a61cc940112786474cf' + assert json_hpp_payment_request_valid.auto_settle_flag == '1' + comment1 = 'a-z A-Z 0-9 \' ", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;' \ + 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥' assert json_hpp_payment_request_valid.comment1 == comment1 - assert json_hpp_payment_request_valid.comment2 == "Comment Two" - assert json_hpp_payment_request_valid.shipping_code == "56|987" - assert json_hpp_payment_request_valid.shipping_co == "IRELAND" - assert json_hpp_payment_request_valid.billing_code == "123|56" - assert json_hpp_payment_request_valid.billing_co == "IRELAND" - assert json_hpp_payment_request_valid.cust_num == "123456" - assert json_hpp_payment_request_valid.var_ref == "VariableRef" - assert json_hpp_payment_request_valid.prod_id == "ProductID" - assert json_hpp_payment_request_valid.hpp_lang == "EN" - assert json_hpp_payment_request_valid.card_payment_button == "Submit Payment" + assert json_hpp_payment_request_valid.comment2 == 'Comment Two' + assert json_hpp_payment_request_valid.shipping_code == '56|987' + assert json_hpp_payment_request_valid.shipping_co == 'IRELAND' + assert json_hpp_payment_request_valid.billing_code == '123|56' + assert json_hpp_payment_request_valid.billing_co == 'IRELAND' + assert json_hpp_payment_request_valid.cust_num == '123456' + assert json_hpp_payment_request_valid.var_ref == 'VariableRef' + assert json_hpp_payment_request_valid.prod_id == 'ProductID' + assert json_hpp_payment_request_valid.hpp_lang == 'EN' + assert json_hpp_payment_request_valid.card_payment_button == 'Submit Payment' def test_to_json_hpp_payment_request(self, json_hpp_payment_request_valid): """ @@ -77,31 +77,31 @@ def test_from_json_hpp_payment_request_supplementary_data(self, json_hpp_payment :param json_hpp_payment_request_supplementary_data: PaymentRequest """ assert isinstance(json_hpp_payment_request_supplementary_data, PaymentRequest) - assert json_hpp_payment_request_supplementary_data.merchant_id == "MerchantID" - assert json_hpp_payment_request_supplementary_data.account == "myAccount" - assert json_hpp_payment_request_supplementary_data.order_id == "OrderID" - assert json_hpp_payment_request_supplementary_data.amount == "100" - assert json_hpp_payment_request_supplementary_data.currency == "EUR" - assert json_hpp_payment_request_supplementary_data.timestamp == "20990101120000" - assert json_hpp_payment_request_supplementary_data.sha1hash == "5d8f05abd618e50db4861a61cc940112786474cf" - assert json_hpp_payment_request_supplementary_data.auto_settle_flag == "1" - comment1 = "a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | =" + assert json_hpp_payment_request_supplementary_data.merchant_id == 'MerchantID' + assert json_hpp_payment_request_supplementary_data.account == 'myAccount' + assert json_hpp_payment_request_supplementary_data.order_id == 'OrderID' + assert json_hpp_payment_request_supplementary_data.amount == '100' + assert json_hpp_payment_request_supplementary_data.currency == 'EUR' + assert json_hpp_payment_request_supplementary_data.timestamp == '20990101120000' + assert json_hpp_payment_request_supplementary_data.sha1hash == '5d8f05abd618e50db4861a61cc940112786474cf' + assert json_hpp_payment_request_supplementary_data.auto_settle_flag == '1' + comment1 = 'a-z A-Z 0-9 \' ", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | =' assert json_hpp_payment_request_supplementary_data.comment1 == comment1 - assert json_hpp_payment_request_supplementary_data.comment2 == "Comment Two" - assert json_hpp_payment_request_supplementary_data.shipping_code == "56|987" - assert json_hpp_payment_request_supplementary_data.shipping_co == "IRELAND" - assert json_hpp_payment_request_supplementary_data.billing_code == "123|56" - assert json_hpp_payment_request_supplementary_data.billing_co == "IRELAND" - assert json_hpp_payment_request_supplementary_data.cust_num == "123456" - assert json_hpp_payment_request_supplementary_data.var_ref == "VariableRef" - assert json_hpp_payment_request_supplementary_data.prod_id == "ProductID" - assert json_hpp_payment_request_supplementary_data.hpp_lang == "EN" - assert json_hpp_payment_request_supplementary_data.card_payment_button == "Submit Payment" + assert json_hpp_payment_request_supplementary_data.comment2 == 'Comment Two' + assert json_hpp_payment_request_supplementary_data.shipping_code == '56|987' + assert json_hpp_payment_request_supplementary_data.shipping_co == 'IRELAND' + assert json_hpp_payment_request_supplementary_data.billing_code == '123|56' + assert json_hpp_payment_request_supplementary_data.billing_co == 'IRELAND' + assert json_hpp_payment_request_supplementary_data.cust_num == '123456' + assert json_hpp_payment_request_supplementary_data.var_ref == 'VariableRef' + assert json_hpp_payment_request_supplementary_data.prod_id == 'ProductID' + assert json_hpp_payment_request_supplementary_data.hpp_lang == 'EN' + assert json_hpp_payment_request_supplementary_data.card_payment_button == 'Submit Payment' assert isinstance(json_hpp_payment_request_supplementary_data.supplementary_data, dict) - assert json_hpp_payment_request_supplementary_data.supplementary_data['SUPPLEMENTARY_1'] == "Supp1" - assert json_hpp_payment_request_supplementary_data.supplementary_data['SUPPLEMENTARY_2'] == "Supp2" - assert json_hpp_payment_request_supplementary_data.supplementary_data['SUPPLEMENTARY_3'] == "Supp3" - assert json_hpp_payment_request_supplementary_data.supplementary_data['SUPPLEMENTARY_4'] == "Supp4" + assert json_hpp_payment_request_supplementary_data.supplementary_data['SUPPLEMENTARY_1'] == 'Supp1' + assert json_hpp_payment_request_supplementary_data.supplementary_data['SUPPLEMENTARY_2'] == 'Supp2' + assert json_hpp_payment_request_supplementary_data.supplementary_data['SUPPLEMENTARY_3'] == 'Supp3' + assert json_hpp_payment_request_supplementary_data.supplementary_data['SUPPLEMENTARY_4'] == 'Supp4' def test_to_json_hpp_payment_request_supplementary_data(self, json_hpp_payment_request_supplementary_data): """ @@ -143,25 +143,25 @@ def test_from_json_hpp_payment_request_encoded(self, json_hpp_payment_request_en :param json_hpp_payment_request_encoded: PaymentRequest """ assert isinstance(json_hpp_payment_request_encoded, PaymentRequest) - assert json_hpp_payment_request_encoded.merchant_id == "MerchantID" - assert json_hpp_payment_request_encoded.account == "myAccount" - assert json_hpp_payment_request_encoded.order_id == "OrderID" - assert json_hpp_payment_request_encoded.amount == "100" - assert json_hpp_payment_request_encoded.currency == "EUR" - assert json_hpp_payment_request_encoded.timestamp == "20990101120000" - assert json_hpp_payment_request_encoded.sha1hash == "5d8f05abd618e50db4861a61cc940112786474cf" - assert json_hpp_payment_request_encoded.comment1 == "Comment Two" - assert json_hpp_payment_request_encoded.comment2 == "Comment Two" - assert json_hpp_payment_request_encoded.auto_settle_flag == "1" - assert json_hpp_payment_request_encoded.shipping_code == "56|987" - assert json_hpp_payment_request_encoded.shipping_co == "IRELAND" - assert json_hpp_payment_request_encoded.billing_code == "123|56" - assert json_hpp_payment_request_encoded.billing_co == "IRELAND" - assert json_hpp_payment_request_encoded.cust_num == "123456" - assert json_hpp_payment_request_encoded.var_ref == "VariableRef" - assert json_hpp_payment_request_encoded.prod_id == "ProductID" - assert json_hpp_payment_request_encoded.hpp_lang == "EN" - assert json_hpp_payment_request_encoded.card_payment_button == "Submit Payment" + assert json_hpp_payment_request_encoded.merchant_id == 'MerchantID' + assert json_hpp_payment_request_encoded.account == 'myAccount' + assert json_hpp_payment_request_encoded.order_id == 'OrderID' + assert json_hpp_payment_request_encoded.amount == '100' + assert json_hpp_payment_request_encoded.currency == 'EUR' + assert json_hpp_payment_request_encoded.timestamp == '20990101120000' + assert json_hpp_payment_request_encoded.sha1hash == '5d8f05abd618e50db4861a61cc940112786474cf' + assert json_hpp_payment_request_encoded.comment1 == 'Comment Two' + assert json_hpp_payment_request_encoded.comment2 == 'Comment Two' + assert json_hpp_payment_request_encoded.auto_settle_flag == '1' + assert json_hpp_payment_request_encoded.shipping_code == '56|987' + assert json_hpp_payment_request_encoded.shipping_co == 'IRELAND' + assert json_hpp_payment_request_encoded.billing_code == '123|56' + assert json_hpp_payment_request_encoded.billing_co == 'IRELAND' + assert json_hpp_payment_request_encoded.cust_num == '123456' + assert json_hpp_payment_request_encoded.var_ref == 'VariableRef' + assert json_hpp_payment_request_encoded.prod_id == 'ProductID' + assert json_hpp_payment_request_encoded.hpp_lang == 'EN' + assert json_hpp_payment_request_encoded.card_payment_button == 'Submit Payment' assert isinstance(json_hpp_payment_request_encoded.supplementary_data, dict) def test_from_json_hpp_card_storage_request(self, json_hpp_card_storage_request_valid): @@ -170,32 +170,32 @@ def test_from_json_hpp_card_storage_request(self, json_hpp_card_storage_request_ :param json_hpp_card_storage_request_valid: CardStorageRequest """ assert isinstance(json_hpp_card_storage_request_valid, CardStorageRequest) - assert json_hpp_card_storage_request_valid.merchant_id == "MerchantID" - assert json_hpp_card_storage_request_valid.account == "myAccount" - assert json_hpp_card_storage_request_valid.order_id == "OrderID" - assert json_hpp_card_storage_request_valid.amount == "100" - assert json_hpp_card_storage_request_valid.currency == "EUR" - assert json_hpp_card_storage_request_valid.timestamp == "20990101120000" - assert json_hpp_card_storage_request_valid.sha1hash == "5d8f05abd618e50db4861a61cc940112786474cf" - assert json_hpp_card_storage_request_valid.auto_settle_flag == "1" - comment1 = "a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;" \ - "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥" + assert json_hpp_card_storage_request_valid.merchant_id == 'MerchantID' + assert json_hpp_card_storage_request_valid.account == 'myAccount' + assert json_hpp_card_storage_request_valid.order_id == 'OrderID' + assert json_hpp_card_storage_request_valid.amount == '100' + assert json_hpp_card_storage_request_valid.currency == 'EUR' + assert json_hpp_card_storage_request_valid.timestamp == '20990101120000' + assert json_hpp_card_storage_request_valid.sha1hash == '5d8f05abd618e50db4861a61cc940112786474cf' + assert json_hpp_card_storage_request_valid.auto_settle_flag == '1' + comment1 = 'a-z A-Z 0-9 \' ", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;' \ + 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥' assert json_hpp_card_storage_request_valid.comment1 == comment1 - assert json_hpp_card_storage_request_valid.comment2 == "Comment Two" - assert json_hpp_card_storage_request_valid.shipping_code == "56|987" - assert json_hpp_card_storage_request_valid.shipping_co == "IRELAND" - assert json_hpp_card_storage_request_valid.billing_code == "123|56" - assert json_hpp_card_storage_request_valid.billing_co == "IRELAND" - assert json_hpp_card_storage_request_valid.cust_num == "123456" - assert json_hpp_card_storage_request_valid.var_ref == "VariableRef" - assert json_hpp_card_storage_request_valid.prod_id == "ProductID" - assert json_hpp_card_storage_request_valid.hpp_lang == "EN" - assert json_hpp_card_storage_request_valid.card_payment_button == "Submit Payment" - assert json_hpp_card_storage_request_valid.card_storage_enable == "1" - assert json_hpp_card_storage_request_valid.offer_save_card == "1" - assert json_hpp_card_storage_request_valid.payer_ref == "PayerRef" - assert json_hpp_card_storage_request_valid.pmt_ref == "PaymentRef" - assert json_hpp_card_storage_request_valid.payer_exist == "1" + assert json_hpp_card_storage_request_valid.comment2 == 'Comment Two' + assert json_hpp_card_storage_request_valid.shipping_code == '56|987' + assert json_hpp_card_storage_request_valid.shipping_co == 'IRELAND' + assert json_hpp_card_storage_request_valid.billing_code == '123|56' + assert json_hpp_card_storage_request_valid.billing_co == 'IRELAND' + assert json_hpp_card_storage_request_valid.cust_num == '123456' + assert json_hpp_card_storage_request_valid.var_ref == 'VariableRef' + assert json_hpp_card_storage_request_valid.prod_id == 'ProductID' + assert json_hpp_card_storage_request_valid.hpp_lang == 'EN' + assert json_hpp_card_storage_request_valid.card_payment_button == 'Submit Payment' + assert json_hpp_card_storage_request_valid.card_storage_enable == '1' + assert json_hpp_card_storage_request_valid.offer_save_card == '1' + assert json_hpp_card_storage_request_valid.payer_ref == 'PayerRef' + assert json_hpp_card_storage_request_valid.pmt_ref == 'PaymentRef' + assert json_hpp_card_storage_request_valid.payer_exist == '1' def test_to_json_hpp_card_storage_request(self, json_hpp_card_storage_request_valid): """ @@ -240,36 +240,36 @@ def test_from_json_hpp_card_storage_request_supp_data(self, json_hpp_card_storag :param json_hpp_card_storage_request_supp_data: CardStorageRequest """ assert isinstance(json_hpp_card_storage_request_supp_data, CardStorageRequest) - assert json_hpp_card_storage_request_supp_data.merchant_id == "MerchantID" - assert json_hpp_card_storage_request_supp_data.account == "myAccount" - assert json_hpp_card_storage_request_supp_data.order_id == "OrderID" - assert json_hpp_card_storage_request_supp_data.amount == "100" - assert json_hpp_card_storage_request_supp_data.currency == "EUR" - assert json_hpp_card_storage_request_supp_data.timestamp == "20990101120000" - assert json_hpp_card_storage_request_supp_data.sha1hash == "5d8f05abd618e50db4861a61cc940112786474cf" - assert json_hpp_card_storage_request_supp_data.auto_settle_flag == "1" - comment1 = "a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | =" + assert json_hpp_card_storage_request_supp_data.merchant_id == 'MerchantID' + assert json_hpp_card_storage_request_supp_data.account == 'myAccount' + assert json_hpp_card_storage_request_supp_data.order_id == 'OrderID' + assert json_hpp_card_storage_request_supp_data.amount == '100' + assert json_hpp_card_storage_request_supp_data.currency == 'EUR' + assert json_hpp_card_storage_request_supp_data.timestamp == '20990101120000' + assert json_hpp_card_storage_request_supp_data.sha1hash == '5d8f05abd618e50db4861a61cc940112786474cf' + assert json_hpp_card_storage_request_supp_data.auto_settle_flag == '1' + comment1 = 'a-z A-Z 0-9 \' ", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | =' assert json_hpp_card_storage_request_supp_data.comment1 == comment1 - assert json_hpp_card_storage_request_supp_data.comment2 == "Comment Two" - assert json_hpp_card_storage_request_supp_data.shipping_code == "56|987" - assert json_hpp_card_storage_request_supp_data.shipping_co == "IRELAND" - assert json_hpp_card_storage_request_supp_data.billing_code == "123|56" - assert json_hpp_card_storage_request_supp_data.billing_co == "IRELAND" - assert json_hpp_card_storage_request_supp_data.cust_num == "123456" - assert json_hpp_card_storage_request_supp_data.var_ref == "VariableRef" - assert json_hpp_card_storage_request_supp_data.prod_id == "ProductID" - assert json_hpp_card_storage_request_supp_data.hpp_lang == "EN" - assert json_hpp_card_storage_request_supp_data.card_payment_button == "Submit Payment" - assert json_hpp_card_storage_request_supp_data.card_storage_enable == "1" - assert json_hpp_card_storage_request_supp_data.offer_save_card == "1" - assert json_hpp_card_storage_request_supp_data.payer_ref == "PayerRef" - assert json_hpp_card_storage_request_supp_data.pmt_ref == "PaymentRef" - assert json_hpp_card_storage_request_supp_data.payer_exist == "1" + assert json_hpp_card_storage_request_supp_data.comment2 == 'Comment Two' + assert json_hpp_card_storage_request_supp_data.shipping_code == '56|987' + assert json_hpp_card_storage_request_supp_data.shipping_co == 'IRELAND' + assert json_hpp_card_storage_request_supp_data.billing_code == '123|56' + assert json_hpp_card_storage_request_supp_data.billing_co == 'IRELAND' + assert json_hpp_card_storage_request_supp_data.cust_num == '123456' + assert json_hpp_card_storage_request_supp_data.var_ref == 'VariableRef' + assert json_hpp_card_storage_request_supp_data.prod_id == 'ProductID' + assert json_hpp_card_storage_request_supp_data.hpp_lang == 'EN' + assert json_hpp_card_storage_request_supp_data.card_payment_button == 'Submit Payment' + assert json_hpp_card_storage_request_supp_data.card_storage_enable == '1' + assert json_hpp_card_storage_request_supp_data.offer_save_card == '1' + assert json_hpp_card_storage_request_supp_data.payer_ref == 'PayerRef' + assert json_hpp_card_storage_request_supp_data.pmt_ref == 'PaymentRef' + assert json_hpp_card_storage_request_supp_data.payer_exist == '1' assert isinstance(json_hpp_card_storage_request_supp_data.supplementary_data, dict) - assert json_hpp_card_storage_request_supp_data.supplementary_data['SUPPLEMENTARY_1'] == "Supp1" - assert json_hpp_card_storage_request_supp_data.supplementary_data['SUPPLEMENTARY_2'] == "Supp2" - assert json_hpp_card_storage_request_supp_data.supplementary_data['SUPPLEMENTARY_3'] == "Supp3" - assert json_hpp_card_storage_request_supp_data.supplementary_data['SUPPLEMENTARY_4'] == "Supp4" + assert json_hpp_card_storage_request_supp_data.supplementary_data['SUPPLEMENTARY_1'] == 'Supp1' + assert json_hpp_card_storage_request_supp_data.supplementary_data['SUPPLEMENTARY_2'] == 'Supp2' + assert json_hpp_card_storage_request_supp_data.supplementary_data['SUPPLEMENTARY_3'] == 'Supp3' + assert json_hpp_card_storage_request_supp_data.supplementary_data['SUPPLEMENTARY_4'] == 'Supp4' def test_to_json_hpp_card_storage_request_supp_data(self, json_hpp_card_storage_request_supp_data): """ @@ -316,26 +316,26 @@ def test_from_json_hpp_card_storage_request_encoded(self, json_hpp_card_storage_ :param json_hpp_card_storage_request_encoded: CardStorageRequest """ assert isinstance(json_hpp_card_storage_request_encoded, CardStorageRequest) - assert json_hpp_card_storage_request_encoded.merchant_id == "MerchantID" - assert json_hpp_card_storage_request_encoded.account == "myAccount" - assert json_hpp_card_storage_request_encoded.order_id == "OrderID" - assert json_hpp_card_storage_request_encoded.amount == "100" - assert json_hpp_card_storage_request_encoded.currency == "EUR" - assert json_hpp_card_storage_request_encoded.timestamp == "20990101120000" - assert json_hpp_card_storage_request_encoded.sha1hash == "5d8f05abd618e50db4861a61cc940112786474cf" - assert json_hpp_card_storage_request_encoded.comment1 == "Comment Two" - assert json_hpp_card_storage_request_encoded.comment2 == "Comment Two" - assert json_hpp_card_storage_request_encoded.auto_settle_flag == "1" - assert json_hpp_card_storage_request_encoded.shipping_code == "56|987" - assert json_hpp_card_storage_request_encoded.shipping_co == "IRELAND" - assert json_hpp_card_storage_request_encoded.billing_code == "123|56" - assert json_hpp_card_storage_request_encoded.billing_co == "IRELAND" - assert json_hpp_card_storage_request_encoded.cust_num == "123456" - assert json_hpp_card_storage_request_encoded.var_ref == "VariableRef" - assert json_hpp_card_storage_request_encoded.prod_id == "ProductID" - assert json_hpp_card_storage_request_encoded.hpp_lang == "EN" - assert json_hpp_card_storage_request_encoded.card_payment_button == "Submit Payment" - assert json_hpp_card_storage_request_encoded.card_storage_enable == "1" - assert json_hpp_card_storage_request_encoded.offer_save_card == "1" - assert json_hpp_card_storage_request_encoded.payer_exist == "0" + assert json_hpp_card_storage_request_encoded.merchant_id == 'MerchantID' + assert json_hpp_card_storage_request_encoded.account == 'myAccount' + assert json_hpp_card_storage_request_encoded.order_id == 'OrderID' + assert json_hpp_card_storage_request_encoded.amount == '100' + assert json_hpp_card_storage_request_encoded.currency == 'EUR' + assert json_hpp_card_storage_request_encoded.timestamp == '20990101120000' + assert json_hpp_card_storage_request_encoded.sha1hash == '5d8f05abd618e50db4861a61cc940112786474cf' + assert json_hpp_card_storage_request_encoded.comment1 == 'Comment Two' + assert json_hpp_card_storage_request_encoded.comment2 == 'Comment Two' + assert json_hpp_card_storage_request_encoded.auto_settle_flag == '1' + assert json_hpp_card_storage_request_encoded.shipping_code == '56|987' + assert json_hpp_card_storage_request_encoded.shipping_co == 'IRELAND' + assert json_hpp_card_storage_request_encoded.billing_code == '123|56' + assert json_hpp_card_storage_request_encoded.billing_co == 'IRELAND' + assert json_hpp_card_storage_request_encoded.cust_num == '123456' + assert json_hpp_card_storage_request_encoded.var_ref == 'VariableRef' + assert json_hpp_card_storage_request_encoded.prod_id == 'ProductID' + assert json_hpp_card_storage_request_encoded.hpp_lang == 'EN' + assert json_hpp_card_storage_request_encoded.card_payment_button == 'Submit Payment' + assert json_hpp_card_storage_request_encoded.card_storage_enable == '1' + assert json_hpp_card_storage_request_encoded.offer_save_card == '1' + assert json_hpp_card_storage_request_encoded.payer_exist == '0' assert isinstance(json_hpp_card_storage_request_encoded.supplementary_data, dict) diff --git a/addonpayments/hpp/tests/utils.py b/addonpayments/hpp/tests/utils.py index 529b48b..cf28b69 100644 --- a/addonpayments/hpp/tests/utils.py +++ b/addonpayments/hpp/tests/utils.py @@ -38,5 +38,5 @@ def hpp_request_storage_enabled(): } -def sample_path(sample): +def get_sample_path(sample): return os.path.join(os.path.dirname(os.path.abspath(__file__)), sample) diff --git a/tox.ini b/tox.ini index e822d58..616c705 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] -envlist = py{27,35}, flake8 +envlist = py{27,33,34,35}, flake8 +skip_missing_interpreters = True [flake8] max-line-length = 120 @@ -12,6 +13,8 @@ commands = basepython = py27: python2.7 + py33: python3.3 + py34: python3.4 py35: python3.5 deps = @@ -20,6 +23,9 @@ deps = pytest-flake8==0.8.1 pytest-eradicate==0.0.3 python-decouple==3.0.0 + attrs==16.3.0 + xmltodict==0.10.2 + requests==2.13.0 future==0.16.0 [testenv:flake8]