Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- run:
name: Run unit tests with coverage
command: |
python -m pytest test/unit/ --cov=trolley --cov-report=xml --cov-report=term || true
python -m pytest -o python_files='test*.py' test/unit/ --cov=trolley --cov-report=xml --cov-report=term
- codecov/upload:
token: CODECOV_TOKEN
slug: trolley/python-sdk
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ $ pip install trolleyhq

```python
from trolley.configuration import Configuration
from trolley.recipients import Recipients

client = Configuration.gateway("ACCESS_KEY","SECRET_KEY")
response = client.recipient.find("R-WJniNq7PUAJetimmJ4")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
requests==2.31.0
requests==2.32.5
mock>=2.0,<3.0
nose>=1.3.7,<2.0
python-dotenv>=1.0.0
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

setup (
name='trolleyhq',
version='1.0.1',
version='1.1.0',
packages=["trolley", "trolley.exceptions", "trolley.utils", "trolley.types"],
package_data={"trolley": ["ssl/*"]},
install_requires=['requests>=2.31.0'],
install_requires=['requests>=2.32.0'],
python_requires='>=3.9',
author='Trolley',
author_email='developer-tools@trolley.com',
summary='Trolley Python SDK',
description='Trolley Python SDK',
url='https://www.trolley.com',
license='MIT',
long_description='A native Python SDK for the Trolley API',
Expand Down
5 changes: 4 additions & 1 deletion test/unit/testBalances.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ def fake_find():
class TestBalances(unittest.TestCase):

def setUp(self):
self.patcher = patch('paymentrails.balances.Balances.find', fake_find)
self.patcher = patch('trolley.types.balances.Balances.find', fake_find)
self.patcher.start()

def tearDown(self):
self.patcher.stop()

public_key = ("publickey")
private_key = ("privatekey")

Expand Down
38 changes: 19 additions & 19 deletions test/unit/testBatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,28 @@ class TestBatch(unittest.TestCase):
public_key = ("public_key")
private_key = ("private_key")

@patch('paymentrails.batch.Batch.find',fake_find)
@patch('trolley.types.batch.Batch.find',fake_find)
def test_retrieve_batch(self):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.find("B-912Q61G0BRVGC")
status = {"ok":"true","batch":{"id":"B-912Q61G0BRVGC","status":"open","amount":"999.00","totalPayments":1,"currency":"USD","description":"Weekly Payouts on 2017-4-4","sentAt":"null","completedAt":"null","createdAt":"2017-05-04T19:19:38.049Z","updatedAt":"2017-05-15T16:38:21.552Z","payments":{"payments":[{"id":"P-91XQ0U0B1RW5M","recipient":{"id":"R-91XPYX3V2MM1G","referenceId":"jsmith@exafmple.com","email":"jsmith@exafmple.com","name":"John Smith","status":"archived","countryCode":"null"},"method":"paypal","methodDisplay":"PayPal","status":"pending","sourceAmount":"999.00","targetAmount":"100.10","isSupplyPayment":"false","memo":"Do something amazing!","fees":"0.00","recipientFees":"0.00","exchangeRate":"1.000000","processedAt":"null","merchantFees":"0.00","sourceCurrency":"USD","sourceCurrencyName":"US Dollar","targetCurrency":"USD","targetCurrencyName":"US Dollar","compliance":{"status":"pending","checkedAt":"null"}}],"meta":{"page":1,"pages":1,"records":1}}}}
self.assertEqual(response, status)

@patch('paymentrails.batch.Batch.find',fake_find)
@patch('trolley.types.batch.Batch.find',fake_find)
def test_retrieve_batch_InvalidBatchId(self):
with self.assertRaises(trolley.exceptions.notFoundException.NotFoundException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.find("dddd")
@patch('paymentrails.batch.Batch.find',fake_find)
@patch('trolley.types.batch.Batch.find',fake_find)
def test_retrieve_batch_None(self):
with self.assertRaises(trolley.exceptions.invalidFieldException.InvalidFieldException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.find(None)

@patch('paymentrails.batch.Batch.update',fake_update)
@patch('trolley.types.batch.Batch.update',fake_update)
def test_update_batch(self):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
Expand All @@ -98,7 +98,7 @@ def test_update_batch(self):
status = {"ok": "true", "object": "updated"}
self.assertEqual(response, status)

@patch('paymentrails.batch.Batch.update',fake_update)
@patch('trolley.types.batch.Batch.update',fake_update)
def test_update_batch_InvalidBatchId(self):
with self.assertRaises(trolley.exceptions.notFoundException.NotFoundException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
Expand All @@ -107,79 +107,79 @@ def test_update_batch_InvalidBatchId(self):
{"id": "P-91XQ0U0B1RW5M", "sourceAmount": 999}]}
response = trolley.types.batch.Batch.update("ddddd",body)

@patch('paymentrails.batch.Batch.update',fake_update)
@patch('trolley.types.batch.Batch.update',fake_update)
def test_update_batch_None_Batch(self):
with self.assertRaises(trolley.exceptions.invalidFieldException.InvalidFieldException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
body = {"update_payments": [
{"id": "P-91XQ0U0B1RW5M", "sourceAmount": 999}]}
response = trolley.types.batch.Batch.update(None,body)
@patch('paymentrails.batch.Batch.update',fake_update)
@patch('trolley.types.batch.Batch.update',fake_update)
def test_update_batch_None_Body(self):
with self.assertRaises(trolley.exceptions.invalidFieldException.InvalidFieldException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.update("B-ddddd",None)
@patch('paymentrails.batch.Batch.delete',fake_delete)
@patch('trolley.types.batch.Batch.delete',fake_delete)
def test_delete_batch(self):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.delete("B-912Q61G0BRVGC")
status = {"ok": "true", "object": "deleted"}
self.assertEqual(response, status)

@patch('paymentrails.batch.Batch.delete',fake_delete)
@patch('trolley.types.batch.Batch.delete',fake_delete)
def test_delete_batch_InvalidBatchId(self):
with self.assertRaises(trolley.exceptions.notFoundException.NotFoundException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.delete("ddddd")
@patch('paymentrails.batch.Batch.delete',fake_delete)
@patch('trolley.types.batch.Batch.delete',fake_delete)
def test_delete_batch_None_Batch(self):
with self.assertRaises(trolley.exceptions.invalidFieldException.InvalidFieldException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.delete(None)
@patch('paymentrails.batch.Batch.search',fake_search)
@patch('trolley.types.batch.Batch.search',fake_search)
def test_list_allBatchesWithQueries(self):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.search(1, 10, "f18")
status = {"ok":"true","batches":[{"id":"B-91XQ40VT5HF18","status":"open","amount":"900.90","totalPayments":1,"currency":"USD","description":"Weekly Payouts on 2017-4-8","sentAt":"null","completedAt":"null","createdAt":"2017-05-08T18:30:44.905Z","updatedAt":"2017-05-12T18:39:06.125Z"}],"meta":{"page":1,"pages":1,"records":1}}
self.assertEqual(response, status)

@patch('paymentrails.batch.Batch.search',fake_search)
@patch('trolley.types.batch.Batch.search',fake_search)
def test_list_allBatchesWithNone(self):
with self.assertRaises(trolley.exceptions.invalidFieldException.InvalidFieldException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.search(1, 10, None)

@patch('paymentrails.batch.Batch.summary',fake_summary)
@patch('trolley.types.batch.Batch.summary',fake_summary)
def test_batch_summary(self):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.summary("B-912Q61G0BRVGC")
status = {"ok":"true","batchSummary":{"id":"B-91XQ40VT5HF18","serverTime":"2017-05-16T13:34:52.026Z","status":"open","currency":"USD","description":"Weekly Payouts on 2017-4-8","sentAt":"null","completedAt":"null","createdAt":"2017-05-08T18:30:44.905Z","processed_by":"API","updatedAt":"2017-05-12T18:39:06.125Z","quoteExpiredAt":"null","errors":[],"methods":{"paypal":{"count":1,"value":900.9,"fees":0,"recipientFees":0,"merchantFees":0,"net":900.9,"accountType":"Gateway","displayName":"PayPal"},"bank-transfer":{"count":0,"value":0,"fees":0,"recipientFees":0,"merchantFees":0,"net":0,"accountType":"PaymentRails","displayName":"Bank Transfer"}},"PaymentRailsTotal":{"count":0,"value":0,"fees":0,"recipientFees":0,"merchantFees":0,"net":0},"GatewayTotal":{"count":1,"value":900.9,"fees":0,"recipientFees":0,"merchantFees":0,"net":900.9},"total":{"count":1,"value":900.9,"fees":0,"recipientFees":0,"merchantFees":0,"net":900.9},"merchantBalances":{"GatewayTotal":0,"PaymentRailsTotal":10000},"enoughFunds":"true"}}
self.assertEqual(response, status)

@patch('paymentrails.batch.Batch.summary',fake_summary)
@patch('trolley.types.batch.Batch.summary',fake_summary)
def test_batch_summary_InvalidBatchId(self):
with self.assertRaises(trolley.exceptions.notFoundException.NotFoundException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.summary("dddd")
@patch('paymentrails.batch.Batch.summary',fake_summary)
@patch('trolley.types.batch.Batch.summary',fake_summary)
def test_batch_summary_None(self):
with self.assertRaises(trolley.exceptions.invalidFieldException.InvalidFieldException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
response = trolley.types.batch.Batch.summary(None)

@patch('paymentrails.batch.Batch.create',fake_create)
@patch('paymentrails.batch.Batch.generate_quote',fake_generate_quote)
@patch('paymentrails.batch.Batch.process_batch',fake_process_batch)
@patch('trolley.types.batch.Batch.create',fake_create)
@patch('trolley.types.batch.Batch.generate_quote',fake_generate_quote)
@patch('trolley.types.batch.Batch.process_batch',fake_process_batch)
def test_create_batch(self):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
trolley.configuration.Configuration.set_private_key(TestBatch.private_key)
Expand All @@ -200,7 +200,7 @@ def test_create_batch(self):
status = {"ok":"true","batch":{"id":"B-91XQ40VT5HF18","status":"processing","amount":"900.90","totalPayments":1,"currency":"USD","description":"Weekly Payouts on 2017-4-8","sentAt":"2017-05-16T13:41:56.149Z","completedAt":"null","createdAt":"2017-05-08T18:30:44.905Z","updatedAt":"2017-05-16T13:41:56.150Z"}}
self.assertEqual(response, status)

@patch('paymentrails.batch.Batch.create',fake_create)
@patch('trolley.types.batch.Batch.create',fake_create)
def test_create_batch_None(self):
with self.assertRaises(trolley.exceptions.invalidFieldException.InvalidFieldException):
trolley.configuration.Configuration.set_public_key(TestBatch.public_key)
Expand Down
Loading