Skip to content

Commit

Permalink
[DRE-94] Add tests (#74)
Browse files Browse the repository at this point in the history
* Initial Structure

* change action branch

* Add tests

* Add tests

* Add base_path from env var

* Add base_path to workflow

* Change readme example

* Change contact name

* Validate oneOf

* Add changelog
  • Loading branch information
ezerozen authored Jun 7, 2023
1 parent fe3762f commit 9af35b4
Show file tree
Hide file tree
Showing 28 changed files with 576 additions and 123 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ jobs:
npm install -g @mockoon/cli
npx mockoon-cli start --data https://raw.githubusercontent.com/conekta/openapi/main/mocks/conekta_api.json --port 3000
- name: Test with pytest
run: |
pytest
run: pytest
env:
BASE_PATH: http://localhost:3000
23 changes: 0 additions & 23 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.github/workflows/python.yml
.gitignore
AUTHORS.md
CODE_OF_CONDUCT.md
Expand Down Expand Up @@ -452,26 +451,4 @@ setup.cfg
setup.py
test-requirements.txt
test/__init__.py
test/test_antifraud_api.py
test/test_api_keys_api.py
test/test_charges_api.py
test/test_companies_api.py
test/test_customers_api.py
test/test_discounts_api.py
test/test_events_api.py
test/test_logs_api.py
test/test_orders_api.py
test/test_payment_link_api.py
test/test_payment_methods_api.py
test/test_plans_api.py
test/test_products_api.py
test/test_shipping_contacts_api.py
test/test_shippings_api.py
test/test_subscriptions_api.py
test/test_taxes_api.py
test/test_tokens_api.py
test/test_transactions_api.py
test/test_transfers_api.py
test/test_webhook_keys_api.py
test/test_webhooks_api.py
tox.ini
84 changes: 84 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## [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

## [2.6.0](https://github.com/conekta/conekta-python/releases/tag/v2.6.0) - 2020-12-30
### Change
- Support creation of a payment link in the SDK.

## [2.5.1](https://github.com/conekta/conekta-python/releases/tag/v2.5.1) - 2019-12-31
### Change
- Adds message field for error object where it was previously missing

## [2.4.0](https://github.com/conekta/conekta-python/releases/tag/v2.4.0) - 2017-09-18
### Change
- Change httplib2 library for requests

## [2.3.4](https://github.com/conekta/conekta-python/releases/tag/v2.3.4) - 2017-06-08
### Feature
- Add void method for the class Order

## [2.3.3]() - 2017-03-24
### Fix
- Fix Subscriptions for Customer

## [2.3.0](https://github.com/conekta/conekta-python/releases/tag/2.3.0) - 2017-02-16
### Update
- Stable version for API 2.0.0
### Feature
- Order model, submodels and methods as well as enhanced errors and lists

## [2.1.0](https://github.com/conekta/conekta-python/releases/tag/2.1.0) - 2017-02-15
### Update
- Merging Api 2.0.0

## [2.0.0](https://github.com/conekta/conekta-python/releases/tag/v2.0) - 2017-01-03
### Feature
- Order's submodels added
### Change
- New Order flow
### Update
- Supporting now API 2.0

## [1.2.0](https://github.com/conekta/conekta-python/releases/tag/v1.2) -
### Feature
- Include locale support and python 3+

## [1.1.1](https://github.com/conekta/conekta-python/releases/tag/v1.1.1) - 2015-02-25
### Feature
- Include charge capture

## [1.1.0](https://github.com/conekta/conekta-python/releases/tag/v1.1.0) - 2014-04-22
### Feature
- Adding payee/payout objects

## [1.0.1](https://github.com/conekta/conekta-python/releases/tag/v1.0.1) - 2014-04-07
### Change
- Bundling source instead of platform specific versions

## [1.0.0](https://github.com/conekta/conekta-python/releases/tag/v1.0.0) - 2013-12-13
### Feature
- Includes subscriptions/tokenization/customers etc

## [0.9.0](https://github.com/conekta/conekta-python/releases/tag/v0.9.0) - 2013-11-15
### Feature
- Adding ssl certs to manifest

## [0.6.5](https://github.com/conekta/conekta-python/releases/tag/v0.6.5) - 2013-11-15
### Update
- Versioning v0.6.5

## [0.7.0](https://github.com/conekta/conekta-python/releases/tag/v0.7) - 2013-10-28
### Change
- Change in refunds, logs and object queries
- Breaking changes to object structure and usage

## [0.6.0](https://github.com/conekta/conekta-python/releases/tag/v0.6) - 2013-09-30
### Feature
- Get all events
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ from __future__ import print_function

import time
import conekta
import os
from conekta.rest import ApiException
from pprint import pprint

Expand All @@ -73,17 +74,21 @@ configuration = conekta.Configuration(
# Enter a context with an instance of the API client
with conekta.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = conekta.AntifraudApi(api_client)
create_risk_rules_data = conekta.CreateRiskRulesData() # CreateRiskRulesData | requested field for blacklist rule
api_instance = conekta.CustomersApi(api_client)
customer = conekta.Customer(
email='[email protected]',
name='Customer Name',
phone='5534343434'
) # Customer | requested field for create Customer
accept_language = 'es' # str | Use for knowing which language to use (optional) (default to 'es')

try:
# Create blacklisted rule
api_response = api_instance.create_rule_blacklist(create_risk_rules_data, accept_language=accept_language)
print("The response of AntifraudApi->create_rule_blacklist:\n")
# Create Customer
api_response = api_instance.create_customer(customer, accept_language=accept_language)
print("The response of CustomersApi->create_customer:\n")
pprint(api_response)
except ApiException as e:
print("Exception when calling AntifraudApi->create_rule_blacklist: %s\n" % e)
print("Exception when calling CustomersApi->create_customer: %s\n" % e)

```

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
NAME = "conekta-python"
NAME = "conekta"
VERSION = "6.0.0"
PYTHON_REQUIRES = ">=3.7"
REQUIRES = [
Expand All @@ -33,9 +33,9 @@
name=NAME,
version=VERSION,
description="Conekta API",
author="Api support client",
author="Engineering Conekta",
author_email="[email protected]",
url="https://developers.conekta.com/",
url="https://github.com/conekta/conekta-python",
keywords=["OpenAPI", "OpenAPI-Generator", "Conekta API"],
install_requires=REQUIRES,
packages=find_packages(exclude=["test", "tests"]),
Expand Down
3 changes: 2 additions & 1 deletion test/test_antifraud_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from conekta import ApiClient
from conekta.api.antifraud_api import AntifraudApi # noqa: E501
from conekta.rest import ApiException
from test.test_utils import get_base_path


class TestAntifraudApi(unittest.TestCase):
"""AntifraudApi unit test stubs"""

def setUp(self):
self.api = conekta.api.antifraud_api.AntifraudApi(ApiClient(
configuration=conekta.Configuration(host='http://localhost:3000')
configuration=conekta.Configuration(host=get_base_path())
)) # noqa: E501

def tearDown(self):
Expand Down
3 changes: 2 additions & 1 deletion test/test_api_keys_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from conekta import ApiClient
from conekta.api.api_keys_api import ApiKeysApi # noqa: E501
from conekta.rest import ApiException
from test.test_utils import get_base_path


class TestApiKeysApi(unittest.TestCase):
"""ApiKeysApi unit test stubs"""

def setUp(self):
self.api = conekta.api.api_keys_api.ApiKeysApi(ApiClient(
configuration=conekta.Configuration(host='http://localhost:3000')
configuration=conekta.Configuration(host=get_base_path())
)) # noqa: E501

def tearDown(self):
Expand Down
10 changes: 9 additions & 1 deletion test/test_charges_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from conekta import ApiClient
from conekta.api.charges_api import ChargesApi # noqa: E501
from conekta.rest import ApiException
from test.test_utils import get_base_path


class TestChargesApi(unittest.TestCase):
"""ChargesApi unit test stubs"""

def setUp(self):
self.api = conekta.api.charges_api.ChargesApi(ApiClient(
configuration=conekta.Configuration(host='http://localhost:3000')
configuration=conekta.Configuration(host=get_base_path())
)) # noqa: E501

def tearDown(self):
Expand All @@ -40,6 +41,10 @@ def test_get_charges(self):
accept_language = 'es'
response = self.api.get_charges(accept_language, limit=20)
self.assertIsNotNone(response)
self.assertIsNotNone(response.data)
self.assertIsNotNone(response.data[0].payment_method)
self.assertIsInstance(response.data[0].payment_method.actual_instance, conekta.PaymentMethodCash)
self.assertEqual('oxxo', response.data[0].payment_method.actual_instance.type)

def test_orders_create_charge(self):
"""Test case for orders_create_charge
Expand All @@ -53,6 +58,9 @@ def test_orders_create_charge(self):
)
response = self.api.orders_create_charge('ord_2tUigJ8DgBhbp6w5D', charge_request, accept_language)
self.assertIsNotNone(response)
self.assertIsNotNone(response.payment_method)
self.assertIsInstance(response.payment_method.actual_instance, conekta.PaymentMethodCard)
self.assertEqual('credit', response.payment_method.actual_instance.type)


if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion test/test_companies_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from conekta import ApiClient
from conekta.api.companies_api import CompaniesApi # noqa: E501
from conekta.rest import ApiException
from test.test_utils import get_base_path


class TestCompaniesApi(unittest.TestCase):
"""CompaniesApi unit test stubs"""

def setUp(self):
self.api = conekta.api.companies_api.CompaniesApi(ApiClient(
configuration=conekta.Configuration(host='http://localhost:3000')
configuration=conekta.Configuration(host=get_base_path())
)) # noqa: E501

def tearDown(self):
Expand Down
13 changes: 12 additions & 1 deletion test/test_customers_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from conekta import ApiClient
from conekta.api.customers_api import CustomersApi # noqa: E501
from conekta.rest import ApiException
from test.test_utils import get_base_path


class TestCustomersApi(unittest.TestCase):
"""CustomersApi unit test stubs"""

def setUp(self):
self.api = conekta.api.customers_api.CustomersApi(ApiClient(
configuration=conekta.Configuration(host='http://localhost:3000')
configuration=conekta.Configuration(host=get_base_path())
)) # noqa: E501

def tearDown(self):
Expand Down Expand Up @@ -82,6 +83,10 @@ def test_get_customer_by_id(self):
accept_language = 'es'
response = self.api.get_customer_by_id('cus_2tYENskzTjjgkGQLt', accept_language)
self.assertIsNotNone(response)
self.assertIsNotNone(response.payment_sources)
self.assertIsNotNone(response.payment_sources.data)
self.assertIsInstance(response.payment_sources.data[0].actual_instance, conekta.PaymentMethodCardResponse)
self.assertEqual('card', response.payment_sources.data[0].actual_instance.type)

def test_get_customers(self):
"""Test case for get_customers
Expand All @@ -91,6 +96,12 @@ def test_get_customers(self):
accept_language = 'es'
response = self.api.get_customers(accept_language, limit=20)
self.assertIsNotNone(response)
self.assertIsNotNone(response.data)
self.assertIsNotNone(response.data[0].payment_sources)
self.assertIsNotNone(response.data[0].payment_sources.data)
self.assertIsInstance(response.data[0].payment_sources.data[0].actual_instance,
conekta.PaymentMethodSpeiRecurrent)
self.assertEqual('spei_recurrent', response.data[0].payment_sources.data[0].actual_instance.type)

def test_update_customer(self):
"""Test case for update_customer
Expand Down
26 changes: 22 additions & 4 deletions test/test_discounts_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@
import unittest

import conekta
from conekta import ApiClient
from conekta.api.discounts_api import DiscountsApi # noqa: E501
from conekta.rest import ApiException
from test.test_utils import get_base_path


class TestDiscountsApi(unittest.TestCase):
"""DiscountsApi unit test stubs"""

def setUp(self):
self.api = conekta.api.discounts_api.DiscountsApi() # noqa: E501
self.api = conekta.api.discounts_api.DiscountsApi(ApiClient(
configuration=conekta.Configuration(host=get_base_path())
)) # noqa: E501

def tearDown(self):
pass
Expand All @@ -34,21 +38,35 @@ def test_orders_create_discount_line(self):
Create Discount # noqa: E501
"""
pass
accept_language = 'es'
rq = conekta.OrderDiscountLinesRequest(
amount=2000,
code='CD',
type='type'
)
response = self.api.orders_create_discount_line('ord_2tUigJ8DgBhbp6w5D', rq, accept_language)
self.assertIsNotNone(response)

def test_orders_delete_discount_lines(self):
"""Test case for orders_delete_discount_lines
Delete Discount # noqa: E501
"""
pass
accept_language = 'es'
response = self.api.orders_delete_discount_lines('ord_2tUigJ8DgBhbp6w5D', 'dis_lin_2tQQ58HPgPw7StE8z', accept_language)
self.assertIsNotNone(response)

def test_orders_update_discount_lines(self):
"""Test case for orders_update_discount_lines
Update Discount # noqa: E501
"""
pass
accept_language = 'es'
rq = conekta.UpdateOrderDiscountLinesRequest(
amount=2000
)
response = self.api.orders_update_discount_lines('ord_2tUigJ8DgBhbp6w5D', 'dis_lin_2tQQ58HPgPw7StE8z', rq, accept_language)
self.assertIsNotNone(response)


if __name__ == '__main__':
Expand Down
Loading

0 comments on commit 9af35b4

Please sign in to comment.