Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed May 14, 2021
1 parent 04456e7 commit 9def78f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, pypy-2.7, pypy-3.7]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy-2.7, pypy-3.7]

steps:
- uses: actions/checkout@v2
Expand All @@ -62,7 +62,7 @@ jobs:
# not fully supported by github actions yet, as of Feb 2021
# https://github.com/actions/cache/issues/81
- name: Start stripe-mock
run: docker run -d -p 12111-12112:12111-12112 stripemock/stripe-mock && sleep 5
run: docker pull stripemock/stripe-mock && docker run -d -p 12111-12112:12111-12112 stripemock/stripe-mock && sleep 5

- name: Test with pytest
run: make test
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cache:
env:
global:
# If changing this number, please also change it in `tests/conftest.py`.
- STRIPE_MOCK_VERSION=0.103.0
- STRIPE_MOCK_VERSION=0.104.0

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
Expand Down
19 changes: 19 additions & 0 deletions tests/api_resources/test_payment_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,22 @@ def test_can_confirm_classmethod(self, request_mock):
"post", "/v1/payment_intents/%s/confirm" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.PaymentIntent)

def test_can_verify_microdeposits(self, request_mock):
resource = stripe.PaymentIntent.retrieve(TEST_RESOURCE_ID)
resource.verify_microdeposits(client_secret="secret", amounts=[1, 2])
request_mock.assert_requested(
"post",
"/v1/payment_intents/%s/verify_microdeposits" % TEST_RESOURCE_ID,
)
assert isinstance(resource, stripe.PaymentIntent)

def test_can_verifymicrodeposits_classmethod(self, request_mock):
resource = stripe.PaymentIntent.verify_microdeposits(
TEST_RESOURCE_ID, client_secret="secret", amounts=[1, 2]
)
request_mock.assert_requested(
"post",
"/v1/payment_intents/%s/verify_microdeposits" % TEST_RESOURCE_ID,
)
assert isinstance(resource, stripe.PaymentIntent)
19 changes: 19 additions & 0 deletions tests/api_resources/test_setup_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,22 @@ def test_can_confirm_classmethod(self, request_mock):
"post", "/v1/setup_intents/%s/confirm" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.SetupIntent)

def test_can_verify_microdeposits(self, request_mock):
resource = stripe.SetupIntent.retrieve(TEST_RESOURCE_ID)
resource.verify_microdeposits(amounts=[1, 2])
request_mock.assert_requested(
"post",
"/v1/setup_intents/%s/verify_microdeposits" % TEST_RESOURCE_ID,
)
assert isinstance(resource, stripe.SetupIntent)

def test_can_verifymicrodeposits_classmethod(self, request_mock):
resource = stripe.SetupIntent.verify_microdeposits(
TEST_RESOURCE_ID, amounts=[1, 2]
)
request_mock.assert_requested(
"post",
"/v1/setup_intents/%s/verify_microdeposits" % TEST_RESOURCE_ID,
)
assert isinstance(resource, stripe.SetupIntent)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


# When changing this number, don't forget to change it in `.travis.yml` too.
MOCK_MINIMUM_VERSION = "0.103.0"
MOCK_MINIMUM_VERSION = "0.104.0"

# Starts stripe-mock if an OpenAPI spec override is found in `openapi/`, and
# otherwise fall back to `STRIPE_MOCK_PORT` or 12111.
Expand Down

0 comments on commit 9def78f

Please sign in to comment.