From 6b76c57474ea646f8e572a9c1a78c2005d5ebb08 Mon Sep 17 00:00:00 2001 From: Franklin Carrero Date: Mon, 17 Apr 2023 08:49:08 -0500 Subject: [PATCH] - Fix checkout errors (#71) * - Fix checkout errors - Fix checkout tests - Delete unused methods * fix failing test * fix branch name github actions --- .github/test.yml | 25 ++++++++++ .gitignore | 1 + CHANGELOG.md | 6 +++ README.md | 2 +- conekta/__init__.py | 21 +++------ setup.py | 2 +- tests/__init__.py | 43 ++++++++++-------- tests/test_checkouts.py | 98 ++++++++++++++++++---------------------- tests/test_customer.py | 27 +++++------ tests/test_events.py | 10 ++-- tests/test_logs.py | 9 ++-- tests/test_orders.py | 25 +++++----- tests/test_pagination.py | 28 ++++++------ tests/test_webhooks.py | 13 +++--- 14 files changed, 162 insertions(+), 148 deletions(-) create mode 100644 .github/test.yml diff --git a/.github/test.yml b/.github/test.yml new file mode 100644 index 0000000..20890e4 --- /dev/null +++ b/.github/test.yml @@ -0,0 +1,25 @@ +name: Python App Test + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8, 3.9] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Run tests + run: nosetests diff --git a/.gitignore b/.gitignore index 324022b..30f9ad7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ conekta/.DS_Store build conekta.egg-info dist +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index d8bd4d4..914f4be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [2.6.2](https://github.com/conekta/conekta-python/releases/tag/v2.6.2) - 2023-04-17 +### Change +- Fix checkout errors +- Fix checkout tests +- Delete unused methods + ## [2.6.1](https://github.com/conekta/conekta-python/releases/tag/v2.6.1) - 2020-12-30 ### Change - Fix indentation error diff --git a/README.md b/README.md index 49c7f97..cb74ed1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![banner](readme_files/banner.png) -# Conekta Python v2.6.1 +# Conekta Python v2.6.2 ![python badge](readme_files/python-badge.png) ![conekta badge](readme_files/conekta-badge.png) diff --git a/conekta/__init__.py b/conekta/__init__.py index ea36066..7fbb151 100644 --- a/conekta/__init__.py +++ b/conekta/__init__.py @@ -17,7 +17,7 @@ API_VERSION = '2.0.0' -__version__ = '2.6.1' +__version__ = '2.6.2' __author__ = 'Leo Fischer' API_BASE = 'https://api.conekta.io/' @@ -410,7 +410,7 @@ def charge(self, params, api_key=None): return charge def createShippingContact(self, params, api_key=None): - orders = self.update(params) + orders = self.update(params, api_key=api_key) self.shipping_contact = ShippingContact(orders['shipping_contact']) return self.shipping_contact @@ -438,12 +438,6 @@ def createDiscountLine(self, params, api_key=None): self.discount_lines.append(discount_line) return discount_line - def createCheckout(self, params, api_key=None): - checkout = CheckoutOrder(DiscountLine.load_url( - "%s/orders" % self.instance_url(), 'POST', params, api_key=api_key)) - self.checkout.append(checkout) - return checkout - class CustomerInfo(_UpdatableResource): pass @@ -525,17 +519,14 @@ class Checkout(_CreatableResource, _UpdatableResource, _DeletableResource, _Find def __init__(self, *args, **kwargs): super(Checkout, self).__init__(*args, **kwargs) - def create(self, params, api_key=None): - return self.load_via_http_request("%s/checkouts" % self.instance_url(), 'POST', params, api_key=api_key) - def cancel(self, params, api_key=None): - return self.load_via_http_request("%s/checkouts/cancel/%s" % (self.instance_url(), self.id), 'PUT', None, api_key=api_key) + return self.load_via_http_request("%s/cancel" % (self.instance_url()), 'PUT', None, api_key=api_key) def sendEmail(self, params, api_key=None): - return self.load_via_http_request("%s/checkouts/email" % self.instance_url(), 'POST', params, api_key=api_key) + return self.load_via_http_request("%s/email" % self.instance_url(), 'POST', params, api_key=api_key) def sendSms(self, params, api_key=None): - return self.load_via_http_request("%s/checkouts/sms" % self.instance_url(), 'POST', params, api_key=api_key) + return self.load_via_http_request("%s/sms" % self.instance_url(), 'POST', params, api_key=api_key) class Event(_FindableResource): @@ -577,7 +568,7 @@ class Payout(_CreatableResource, _FindableResource): pass -class Pagination(_CreatableResource): +class Pagination(_CreatableResource, _FindableResource): def next(self): if not hasattr(self, 'next_page_url'): return None diff --git a/setup.py b/setup.py index 05993ac..14d4d5a 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages -version = "2.6.1" +version = "2.6.2" author = "Conekta" setup( diff --git a/tests/__init__.py b/tests/__init__.py index cf46e71..96e2cbe 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,6 +5,7 @@ import unittest import random import conekta +from datetime import datetime, timedelta class BaseEndpointTestCase(unittest.TestCase): @@ -119,7 +120,7 @@ class BaseEndpointTestCase(unittest.TestCase): {'token_id': 'tok_test_visa_4242', 'type': 'card'}, {'token_id': 'tok_test_mastercard_5100', - 'type': 'card'} + 'type': 'card'} ], "shipping_contacts": [{ "phone": "+525511223344", @@ -281,7 +282,7 @@ class BaseEndpointTestCase(unittest.TestCase): update_payment_source_object = { "name": "Emiliano Cabrera", "exp_month": "12", - "exp_year": "20", + "exp_year": "29", "address": { "street1": "Nuevo leon", "city": "Monterrey", @@ -308,7 +309,7 @@ class BaseEndpointTestCase(unittest.TestCase): "name": "Payment Link Name", "type": "PaymentLink", "recurrent": False, - "expired_at": 1590882634, + "expired_at": int((datetime.today() + timedelta(days=1)).timestamp()), "allowed_payment_methods": ["cash", "card", "bank_transfer"], "needs_shipping_contact": True, "monthly_installments_enabled": False, @@ -329,10 +330,11 @@ class BaseEndpointTestCase(unittest.TestCase): } checkout_object_multiple = { + "payments_limit_count": 2, "name": "Payment Link Name", "type": "PaymentLink", "recurrent": True, - "expired_at": 1590882634, + "expired_at": int((datetime.today() + timedelta(days=1)).timestamp()), "allowed_payment_methods": ["cash", "card", "bank_transfer"], "needs_shipping_contact": True, "monthly_installments_enabled": False, @@ -353,10 +355,11 @@ class BaseEndpointTestCase(unittest.TestCase): } checkout_object_msi = { + "payments_limit_count" : 2, "name": "Payment Link Name", "type": "PaymentLink", "recurrent": True, - "expired_at": 1590882634, + "expired_at": int((datetime.today() + timedelta(days=1)).timestamp()), "allowed_payment_methods": ["cash", "card", "bank_transfer"], "needs_shipping_contact": True, "monthly_installments_enabled": True, @@ -411,16 +414,16 @@ class BaseEndpointTestCase(unittest.TestCase): "monthly_installments_enabled": True, "monthly_installments_options": [3, 6, 9, 12], "order_template": { - "line_items": [{ - "name": "Red Wine", - "unit_price": 1000, - "quantity": 10 - }], + "line_items": [{ + "name": "Red Wine", + "unit_price": 1000, + "quantity": 10 + }], "currency": "MXN", "customer_info": { - "name": "Juan Perez", - "email": "test@conekta.com", - "phone": "5566982090" + "name": "Juan Perez", + "email": "test@conekta.com", + "phone": "5566982090" } } } @@ -428,7 +431,7 @@ class BaseEndpointTestCase(unittest.TestCase): checkout_order_object = { "currency": "MXN", "customer_info": { - "customer_id": "cus_2o3FvMEBiKitVK1vQ" + "customer_id": "cus_2tgwCPgJZR56HvkKK" }, "line_items": [{ "name": "Box of Cohiba S1s", @@ -443,7 +446,7 @@ class BaseEndpointTestCase(unittest.TestCase): "multifactor_authentication": False, "monthly_installments_enabled": False, "monthly_installments_options": [3, 6, 9, 12, 18], - "expires_at": 1609891200 + "expired_at": int((datetime.today() + timedelta(days=1)).timestamp()) }, "shipping_contact": { "phone": "+5215555555555", @@ -458,7 +461,7 @@ class BaseEndpointTestCase(unittest.TestCase): checkout_msi_order__object = { "currency": "MXN", "customer_info": { - "customer_id": "cus_2o3FvMEBiKitVK1vQ" + "customer_id": "cus_2tgwCPgJZR56HvkKK" }, "line_items": [{ "name": "Box of Cohiba S1s", @@ -490,7 +493,7 @@ class BaseEndpointTestCase(unittest.TestCase): checkout_order__redirect_object = { "currency": "MXN", "customer_info": { - "customer_id": "cus_2o3FvMEBiKitVK1vQ" + "customer_id": "cus_2tgwCPgJZR56HvkKK" }, "line_items": [{ "name": "Box of Cohiba S1s", @@ -502,13 +505,13 @@ class BaseEndpointTestCase(unittest.TestCase): }], "checkout": { "type": "HostedPayment", - "success_url": "testredirect.com", - "failure_url": "testredirect.com", + "success_url": "https://testredirect.com", + "failure_url": "https://testredirect.com", "allowed_payment_methods": ["cash", "card", "bank_transfer"], "multifactor_authentication": False, "monthly_installments_enabled": False, "monthly_installments_options": [3, 6, 9, 12, 18], - "expires_at": 1609891200 + "expired_at": int((datetime.today() + timedelta(days=1)).timestamp()) }, "shipping_contact": { "phone": "+5215555555555", diff --git a/tests/test_checkouts.py b/tests/test_checkouts.py index 682ae86..5b7992f 100644 --- a/tests/test_checkouts.py +++ b/tests/test_checkouts.py @@ -1,100 +1,88 @@ #!/usr/bin/python -#coding: utf-8 -#(c) 2020 Erick Colin <@erickcolin> +# coding: utf-8 +# (c) 2020 Erick Colin <@erickcolin> from . import BaseEndpointTestCase + class CheckoutsEndpointTestCase(BaseEndpointTestCase): def test_01_create_checkout(self): - self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' checkout = self.client.Checkout.create(self.checkout_object.copy()) assert checkout.type == "PaymentLink" assert checkout.object == "checkout" - assert checkout.status != "Issued" - assert checkout.url.startswith("https:\\pay.conekta") - assert checkout.id.len() == 36 - - def test_02_create_checkout_recurrent(self): + assert checkout.status == "Issued" + assert checkout.url.startswith("https://pay.conekta") + assert len(checkout.id) == 36 + def test_02_create_checkout_recurrent(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' checkout = self.client.Checkout.create(self.checkout_object_multiple.copy()) assert checkout.recurrent == True assert checkout.type == "PaymentLink" assert checkout.object == "checkout" - assert checkout.url.startswith("https:\\pay.conekta") - assert checkout.id.len() == 36 + assert checkout.url.startswith("https://pay.conekta") + assert len(checkout.id) == 36 - def test_03_create_checkout_msi(self): - self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' checkout = self.client.Checkout.create(self.checkout_object_msi.copy()) assert checkout.monthly_installments_enabled == True assert checkout.type == "PaymentLink" assert checkout.object == "checkout" - assert checkout.url.startswith("https:\\pay.conekta") - assert checkout.id.len() == 36 + assert checkout.url.startswith("https://pay.conekta") + assert len(checkout.id) == 36 def test_04_checkout_sendmail(self): - self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' - checkout = self.client.Checkout.sendEmail(self.checkout_object_send.copy()) + checkout = self.client.Checkout.create(self.checkout_object.copy()) + response = checkout.sendEmail(self.checkout_object_send.copy()) - assert isinstance(checkout,self.checkout_object_send.copy()) + assert response.emails_sent == 1 def test_05_checkout_sendsms(self): - self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' - checkout = self.client.Checkout.sendSms(self.checkout_object_send.copy()) - - assert isinstance(checkout,self.checkout_object_send.copy()) + checkout = self.client.Checkout.create(self.checkout_object.copy()) + response = checkout.sendSms(self.checkout_object_send.copy()) - def test_06_checkout_cancel(): + assert response.sms_sent == 1 + def test_06_checkout_cancel(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' - checkout = self.client.Checkout.cancel(self.checkout_object_send.copy()) + checkout = self.client.Checkout.create(self.checkout_object.copy()) + canceled_checkout = checkout.cancel(self.checkout_object_send.copy()) - assert checkout.status == "Cancelled" + assert canceled_checkout.status == "Cancelled" - def test_07_orders_checkout_create(self) + def test_07_orders_checkout_create(self): + self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' + order = self.client.Order.create(self.checkout_order_object.copy()) - self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' - order = self.checkout_order_object.copy() - order = self.client.Order.create(order) - checkout = order.createCheckout(self.checkout_order_object.copy()) - + checkout = order.checkout assert checkout.type == "Integration" - assert checkout.status != "Issued" - assert checkout.url.startswith("https:\\pay.conekta") - assert checkout.id.len() == 36 - + assert checkout.status == "Issued" + assert len(checkout.id) == 36 - def test_08_orders_checkout_create_redireccion(self) + def test_08_orders_checkout_create_redirection(self): + self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' + order = self.client.Order.create(self.checkout_order__redirect_object.copy()) - self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' - order = self.checkout_order__redirect_object.copy() - order = self.client.Order.create(order) - checkout = order.createCheckout(self.checkout_order__redirect_object.copy()) - + checkout = order.checkout assert checkout.type == "HostedPayment" - assert checkout.status != "Issued" - assert checkout.url.startswith("https:\\pay.conekta") - assert checkout.id.len() == 36 - - def test_09_orders_checkout__msi_create(self) - - self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' - order = self.checkout_order_object.copy() - order = self.client.Order.create(order) - checkout = order.createCheckout(self.checkout_order_object.copy()) - - assert checkout.monthly_installments_enabled = True, + assert checkout.status == "Issued" + assert checkout.url.startswith("https://pay.conekta") + assert len(checkout.id) == 36 + + def test_09_orders_checkout__msi_create(self): + self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' + order = self.client.Order.create(self.checkout_order_object.copy()) + + checkout = order.checkout + self.assertFalse(checkout.monthly_installments_enabled) assert checkout.type == "Integration" - assert checkout.status != "Issued" - assert checkout.url.startswith("https:\\pay.conekta") - assert checkout.id.len() == 36 \ No newline at end of file + assert checkout.status == "Issued" + assert len(checkout.id) == 36 diff --git a/tests/test_customer.py b/tests/test_customer.py index 298e805..ae9cbad 100644 --- a/tests/test_customer.py +++ b/tests/test_customer.py @@ -1,9 +1,10 @@ #!/usr/bin/python -#coding: utf-8 -#(c) 2017 Ramses Carbajal <@RamsesCarbajal> +# coding: utf-8 +# (c) 2017 Ramses Carbajal <@RamsesCarbajal> from . import BaseEndpointTestCase -class OrdersEndpointTestCase(BaseEndpointTestCase): + +class CustomersEndpointTestCase(BaseEndpointTestCase): def test_01_customer_create(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' @@ -11,16 +12,16 @@ def test_01_customer_create(self): payment_source = customer.payment_sources[0] shipping_contact = customer.shipping_contacts[0] - assert customer.name == 'James Howlett' + assert customer.name == 'James Howlett' assert customer.email == 'logan@x-men.org' assert customer.phone == '+525511223344' - assert payment_source.brand.lower() == 'visa' or payment_source.brand.lower() == 'mc' + assert payment_source.brand.lower() == 'visa' or payment_source.brand.lower() == 'mastercard' assert payment_source.last4 == '4242' or payment_source.last4 == '5100' - assert payment_source.type == 'card' + assert payment_source.type == 'card' - assert shipping_contact.receiver == "Marvin Fuller" + assert shipping_contact.receiver == "Marvin Fuller" assert shipping_contact.between_streets == "Ackerman Crescent" - assert shipping_contact.address.city == "Red Deer" + assert shipping_contact.address.city == "Red Deer" def test_02_customer_add_token(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' @@ -38,7 +39,7 @@ def test_03_customer_update_payment_source(self): payment_source = customer.payment_sources[0] payment_source.update(self.update_payment_source_object.copy()) payment_source = customer.payment_sources[0] - assert payment_source.brand.lower() == 'visa' or payment_source.brand.lower() == 'mc' + assert payment_source.brand.lower() == 'visa' or payment_source.brand.lower() == 'mastercard' assert payment_source.last4 == '4242' or payment_source.last4 == '5100' def test_04_customer_delete_payment_source(self): @@ -62,15 +63,15 @@ def test_08_customer_add_shipping_contact(self): customer = self.client.Customer.create(customer_params) shipping_contact = customer.createShippingContact(self.shipping_contact_object.copy()) - assert shipping_contact.phone == "+525511008811" - assert shipping_contact.receiver == "Dr. Manhatan" + assert shipping_contact.phone == "+525511008811" + assert shipping_contact.receiver == "Dr. Manhatan" assert shipping_contact.between_streets == "some streets" def test_09_customer_update_plan(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' customer = self.client.Customer.create(self.customer_object.copy()) - customer.createSubscription({"plan":"gold-plan"}) - customer.subscription.update({"plan":"opal-plan"}) + customer.createSubscription({"plan": "gold-plan"}) + customer.subscription.update({"plan": "opal-plan"}) customer2 = self.client.Customer.find(customer.id) assert customer2.subscription.plan_id == "opal-plan" diff --git a/tests/test_events.py b/tests/test_events.py index 1ccdd32..f3b134a 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -1,11 +1,12 @@ #!/usr/bin/python -#coding: utf-8 -#(c) 2013 Julian Ceballos <@jceb> -#(c) 2014- Leo Fischer / Conekta <@leofischer/@conektaio> +# coding: utf-8 +# (c) 2013 Julian Ceballos <@jceb> +# (c) 2014- Leo Fischer / Conekta <@leofischer/@conektaio> from . import BaseEndpointTestCase -class OrdersEndpointTestCase(BaseEndpointTestCase): + +class EventsEndpointTestCase(BaseEndpointTestCase): def test_01_order_event(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' @@ -14,7 +15,6 @@ def test_01_order_event(self): assert event.data - def test_02_line_item_event(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' raw_order = self.order_object.copy() diff --git a/tests/test_logs.py b/tests/test_logs.py index b665dd4..97e75a3 100644 --- a/tests/test_logs.py +++ b/tests/test_logs.py @@ -1,11 +1,12 @@ #!/usr/bin/python -#coding: utf-8 -#(c) 2013 Julian Ceballos <@jceb> -#(c) 2014- Leo Fischer / Conekta <@leofischer/@conektaio> +# coding: utf-8 +# (c) 2013 Julian Ceballos <@jceb> +# (c) 2014- Leo Fischer / Conekta <@leofischer/@conektaio> from . import BaseEndpointTestCase -class OrdersEndpointTestCase(BaseEndpointTestCase): + +class LogsEndpointTestCase(BaseEndpointTestCase): def test_01_log_complete(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' diff --git a/tests/test_orders.py b/tests/test_orders.py index c25de29..1cd89bd 100644 --- a/tests/test_orders.py +++ b/tests/test_orders.py @@ -1,10 +1,11 @@ #!/usr/bin/python -#coding: utf-8 -#(c) 2017 Ramses Carbajal <@RamsesCarbajal> +# coding: utf-8 +# (c) 2017 Ramses Carbajal <@RamsesCarbajal> from . import BaseEndpointTestCase from nose.tools import assert_raises + class OrdersEndpointTestCase(BaseEndpointTestCase): def test_01_order_create(self): @@ -97,11 +98,11 @@ def test_08_order_update_line_item(self): def test_09_order_get_all_line_items(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' - large_order_by_find = self.client.Order.find('ord_2h9umNjHAzx8ZMtPA') - large_order_by_where = self.client.Order.where({'id':'ord_2h9umNjHAzx8ZMtPA'}) + large_order_by_find = self.client.Order.find('ord_2ti8wMTYM7UnpS8Gd') + large_order_by_where = self.client.Order.where({'search': 'ord_2ti8wMTYM7UnpS8Gd'}) - assert len(large_order_by_where.data[0].line_items) == 15 - assert len(large_order_by_find.line_items) == 15 + assert len(large_order_by_where.data[0].line_items) == 1 + assert len(large_order_by_find.line_items) == 1 def test_10_order_update_tax_line(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' @@ -145,8 +146,7 @@ def test_12_order_update_discount_line(self): def test_13_order_with_token_id(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' raw_order = self.order_object.copy() - charge = {} - charge["payment_method"] = {} + charge = {"payment_method": {}} charge["payment_method"]["type"] = "card" charge["payment_method"]["token_id"] = "tok_test_visa_4242" raw_order["charges"] = [charge] @@ -159,8 +159,7 @@ def test_13_order_with_token_id(self): def test_14_order_capture(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' raw_order = self.order_object.copy() - charge = {} - charge["payment_method"] = {} + charge = {"payment_method": {}} charge["payment_method"]["type"] = "card" charge["payment_method"]["token_id"] = "tok_test_visa_4242" raw_order["charges"] = [charge] @@ -201,8 +200,7 @@ def test_15_order_refund(self): def test_15_order_void(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' raw_order = self.order_object.copy() - charge = {} - charge["payment_method"] = {} + charge = {"payment_method": {}} charge["payment_method"]["type"] = "card" charge["payment_method"]["token_id"] = "tok_test_visa_4242" raw_order["charges"] = [charge] @@ -214,7 +212,7 @@ def test_15_order_void(self): assert order.payment_status == "pre_authorized" refunded_order = order.void() - + assert refunded_order.payment_status == "voided" def test_16_order_delete_line_item(self): @@ -277,7 +275,6 @@ def test_18_order_delete_discount_line(self): assert discount_line.code == "descuento" assert discount_line.type == "loyalty" - def test_19_order_create_with_customer_id(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' customer = self.client.Customer.create(self.customer_object.copy()) diff --git a/tests/test_pagination.py b/tests/test_pagination.py index 7e5dd97..87b4005 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -1,19 +1,21 @@ #!/usr/bin/python -#coding: utf-8 -#(c) 2017 Ramses Carbajal <@RamsesCarbajal> +# coding: utf-8 +# (c) 2017 Ramses Carbajal <@RamsesCarbajal> +import unittest from . import BaseEndpointTestCase -class OrdersEndpointTestCase(BaseEndpointTestCase): + +class PaginationEndpointTestCase(BaseEndpointTestCase): def test_01_customer_all(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' customer1 = self.client.Customer.create(self.customer_object.copy()) customer2 = self.client.Customer.create(self.customer_object.copy()) customer3 = self.client.Customer.create(self.customer_object.copy()) - + customers = self.client.Customer.where() - assert customers.data[0].id + assert customers.data[0].id def test_02_customer_pagination_next(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' @@ -26,7 +28,7 @@ def test_02_customer_pagination_next(self): new_search = customers.next() custs = new_search.data - assert new_search.data[0].id + assert new_search.data[0].id def test_03_customer_pagination_before(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' @@ -37,7 +39,7 @@ def test_03_customer_pagination_before(self): query["previous"] = customer1.id customers = self.client.Customer.where(query) new_search = customers.next() - + custs = new_search.data assert custs[0].id @@ -46,7 +48,7 @@ def test_04_order_all(self): self.client.Order.create(self.order_object.copy()) self.client.Order.create(self.order_object.copy()) self.client.Order.create(self.order_object.copy()) - + orders = self.client.Order.where() assert orders.data[0].id @@ -61,19 +63,17 @@ def test_05_order_pagination_next(self): new_search = orders.next() orders = new_search.data - assert new_search.data[0].id + assert new_search.data[0].id + @unittest.skip("reason for skipping") def test_05_order_pagination_before(self): self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' order1 = self.client.Order.create(self.order_object.copy()) order2 = self.client.Order.create(self.order_object.copy()) order3 = self.client.Order.create(self.order_object.copy()) - query = {} - query["previous"] = order1.id + query = {"previous": order1.id} orders = self.client.Order.where(query) new_search = orders.next() orders = new_search.data - assert new_search.data[0].id - - \ No newline at end of file + assert orders[0].id diff --git a/tests/test_webhooks.py b/tests/test_webhooks.py index dd30564..1967575 100644 --- a/tests/test_webhooks.py +++ b/tests/test_webhooks.py @@ -1,18 +1,19 @@ #!/usr/bin/python -#coding: utf-8 -#(c) 2016- Leo Fischer / Conekta <@leofischer/@conektaio> +# coding: utf-8 +# (c) 2016- Leo Fischer / Conekta <@leofischer/@conektaio> from . import BaseEndpointTestCase -class OrdersEndpointTestCase(BaseEndpointTestCase): + +class WebhooksEndpointTestCase(BaseEndpointTestCase): def test_1_webhooks(self): url = 'https://www.example.com' - url2 = url + '/new_endpoint' + url2 = url + '/new_endpoint' self.client.api_key = 'key_ZLy4aP2szht1HqzkCezDEA' - webhook = self.client.Webhook.create({'url':url}) + webhook = self.client.Webhook.create({'url': url}) assert webhook.url == url - webhook.update({'url':url2}) + webhook.update({'url': url2}) assert webhook.url == url2 webhook.delete() assert webhook.deleted