Skip to content

Commit

Permalink
Add support for Terminal Location and Reader deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Mar 18, 2019
1 parent bcec86e commit a028dd7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 34 deletions.
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):
# 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

0 comments on commit a028dd7

Please sign in to comment.