Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Terminal Location and Reader deletion #542

Merged
merged 1 commit into from
Mar 19, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cache:
env:
global:
# If changing this number, please also change it in `tests/conftest.py`.
- STRIPE_MOCK_VERSION=0.44.0
- STRIPE_MOCK_VERSION=0.49.0

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
Expand Down
6 changes: 5 additions & 1 deletion stripe/api_resources/terminal/location.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from __future__ import absolute_import, division, print_function

from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import DeletableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource


class Location(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
DeletableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "terminal.location"
6 changes: 5 additions & 1 deletion stripe/api_resources/terminal/reader.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from __future__ import absolute_import, division, print_function

from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import DeletableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource


class Reader(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
DeletableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "terminal.reader"
8 changes: 8 additions & 0 deletions tests/api_resources/terminal/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ def test_is_saveable(self, request_mock):
)
assert isinstance(resource, stripe.terminal.Location)
assert resource is location

def test_is_deletable(self, request_mock):
resource = stripe.terminal.Location.retrieve(TEST_RESOURCE_ID)
resource.delete()
request_mock.assert_requested(
"delete", "/v1/terminal/locations/%s" % TEST_RESOURCE_ID
)
assert resource.deleted is True
8 changes: 8 additions & 0 deletions tests/api_resources/terminal/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ def test_is_saveable(self, request_mock):
)
assert isinstance(resource, stripe.terminal.Reader)
assert resource is reader

def test_is_deletable(self, request_mock):
resource = stripe.terminal.Reader.retrieve(TEST_RESOURCE_ID)
resource.delete()
request_mock.assert_requested(
"delete", "/v1/terminal/readers/%s" % TEST_RESOURCE_ID
)
assert resource.deleted is True
30 changes: 0 additions & 30 deletions tests/api_resources/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,6 @@ def test_is_saveable(self, request_mock):
assert isinstance(resource, stripe.Account)
assert resource is account

def test_is_saveable_with_additional_owners(self, request_mock):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to remove the test as openapi does not support legal_entity anymore. We could mock if needed but I think it's fine to punt on that test.

# stripe-mock does not return additional owners so we construct
account = stripe.Account.construct_from(
{
"id": "%s" % TEST_RESOURCE_ID,
"legal_entity": {
"additional_owners": [
{"first_name": "name", "verification": {}}
]
},
},
stripe.api_key,
)
owner = account.legal_entity.additional_owners[0]
owner.verification.document = "file_foo"
resource = account.save()
request_mock.assert_requested(
"post",
"/v1/accounts/%s" % TEST_RESOURCE_ID,
{
"legal_entity": {
"additional_owners": {
"0": {"verification": {"document": "file_foo"}}
}
}
},
)
assert isinstance(resource, stripe.Account)
assert resource is account

def test_is_saveable_with_individual(self, request_mock):
individual = stripe.Person.construct_from(
{"id": "person_123", "object": "person", "first_name": "Jenny"},
Expand Down
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.44.0"
MOCK_MINIMUM_VERSION = "0.49.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