Skip to content
Open
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 gocardless_pro/services/mandate_pdfs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create(self,params=None, headers=None):

To generate a PDF mandate in another language, set the
`Accept-Language` header when creating the PDF mandate to the relevant
[ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
[ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
language code supported for the scheme.

| Scheme | Supported languages
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/outbound_payments_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def approve(self,identity,params=None, headers=None):
"""Approve an outbound payment.

Approves an outbound payment. Only outbound payments with the
pending_approval status can be approved.
"pending_approval" status can be approved.

Args:
identity (string): Unique identifier of the outbound payment.
Expand Down
1 change: 1 addition & 0 deletions tests/code_samples/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Code sample tests
53 changes: 53 additions & 0 deletions tests/code_samples/balances_code_samples_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
#

# Code Sample Tests
# These tests verify that the documentation code samples are syntactically valid
# and can execute against a mocked API without errors.
#
# IMPORTANT: These tests do NOT verify business logic - they only verify that
# the code samples compile and execute without syntax errors.

import re
import sys
from io import StringIO

import responses

import gocardless_pro






@responses.activate
def test_balances_list_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/balances'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'balances': [{}], 'meta': { 'cursors': {'after': None, 'before': None}, 'limit': 50 } }
for _ in range(5):
responses.add(
'GET',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.balances.list(params={
"creditor": "CR123",
}).records
finally:
sys.stdout = old_stdout


53 changes: 53 additions & 0 deletions tests/code_samples/bank_account_details_code_samples_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
#

# Code Sample Tests
# These tests verify that the documentation code samples are syntactically valid
# and can execute against a mocked API without errors.
#
# IMPORTANT: These tests do NOT verify business logic - they only verify that
# the code samples compile and execute without syntax errors.

import re
import sys
from io import StringIO

import responses

import gocardless_pro






@responses.activate
def test_bank_account_details_get_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/bank_account_details/:identity'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'bank_account_details': {} }
for _ in range(5):
responses.add(
'GET',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.bank_account_details.get("BA123",
headers={'Gc-Key-Id': 'PK123'}
)
finally:
sys.stdout = old_stdout


Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
#

# Code Sample Tests
# These tests verify that the documentation code samples are syntactically valid
# and can execute against a mocked API without errors.
#
# IMPORTANT: These tests do NOT verify business logic - they only verify that
# the code samples compile and execute without syntax errors.

import re
import sys
from io import StringIO

import responses

import gocardless_pro






@responses.activate
def test_bank_account_holder_verifications_create_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/bank_account_holder_verifications'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'bank_account_holder_verifications': {} }
for _ in range(5):
responses.add(
'POST',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.bank_account_holder_verifications.create(params={
"type": "confirmation_of_payee",
"links": {
"bank_account": "BA123"
}
})
finally:
sys.stdout = old_stdout




@responses.activate
def test_bank_account_holder_verifications_get_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/bank_account_holder_verifications/:identity'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'bank_account_holder_verifications': {} }
for _ in range(5):
responses.add(
'GET',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.bank_account_holder_verifications.get("BAHV123")
finally:
sys.stdout = old_stdout


84 changes: 84 additions & 0 deletions tests/code_samples/bank_authorisations_code_samples_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
#

# Code Sample Tests
# These tests verify that the documentation code samples are syntactically valid
# and can execute against a mocked API without errors.
#
# IMPORTANT: These tests do NOT verify business logic - they only verify that
# the code samples compile and execute without syntax errors.

import re
import sys
from io import StringIO

import responses

import gocardless_pro






@responses.activate
def test_bank_authorisations_create_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/bank_authorisations'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'bank_authorisations': {} }
for _ in range(5):
responses.add(
'POST',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.bank_authorisations.create(params={
"redirect_uri": "https://my-company.com/landing",
"links": {
"billing_request": "BRQ123"
}
})
finally:
sys.stdout = old_stdout




@responses.activate
def test_bank_authorisations_get_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/bank_authorisations/:identity'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'bank_authorisations': {} }
for _ in range(5):
responses.add(
'GET',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.bank_authorisations.get("BAU123")
finally:
sys.stdout = old_stdout


55 changes: 55 additions & 0 deletions tests/code_samples/bank_details_lookups_code_samples_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
#

# Code Sample Tests
# These tests verify that the documentation code samples are syntactically valid
# and can execute against a mocked API without errors.
#
# IMPORTANT: These tests do NOT verify business logic - they only verify that
# the code samples compile and execute without syntax errors.

import re
import sys
from io import StringIO

import responses

import gocardless_pro






@responses.activate
def test_bank_details_lookups_create_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/bank_details_lookups'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'bank_details_lookups': {} }
for _ in range(5):
responses.add(
'POST',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.bank_details_lookups.create(params={
"account_number": "55779911",
"branch_code": "200000",
"country_code": "GB"
})
finally:
sys.stdout = old_stdout


Loading
Loading