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 Radar List and ListItem resources #489

Merged
merged 1 commit into from
Nov 27, 2018
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 .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.35.0
- STRIPE_MOCK_VERSION=0.37.0

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
Expand Down
1 change: 1 addition & 0 deletions stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# API resources
from stripe.api_resources import * # noqa
from stripe.api_resources import issuing # noqa
from stripe.api_resources import radar # noqa
from stripe.api_resources import reporting # noqa
from stripe.api_resources import sigma # noqa
from stripe.api_resources import terminal # noqa
Expand Down
6 changes: 6 additions & 0 deletions stripe/api_resources/radar/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from __future__ import absolute_import, division, print_function

# flake8: noqa

from stripe.api_resources.radar.value_list import ValueList
from stripe.api_resources.radar.value_list_item import ValueListItem
11 changes: 11 additions & 0 deletions stripe/api_resources/radar/value_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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 ValueList(CreateableAPIResource, UpdateableAPIResource,
DeletableAPIResource, ListableAPIResource):
OBJECT_NAME = 'radar.value_list'
10 changes: 10 additions & 0 deletions stripe/api_resources/radar/value_list_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 ListableAPIResource


class ValueListItem(CreateableAPIResource, DeletableAPIResource,
ListableAPIResource):
OBJECT_NAME = 'radar.value_list_item'
4 changes: 4 additions & 0 deletions stripe/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ def load_object_classes():
api_resources.Person.OBJECT_NAME: api_resources.Person,
api_resources.Plan.OBJECT_NAME: api_resources.Plan,
api_resources.Product.OBJECT_NAME: api_resources.Product,
api_resources.radar.ValueList.OBJECT_NAME:
api_resources.radar.ValueList,
api_resources.radar.ValueListItem.OBJECT_NAME:
api_resources.radar.ValueListItem,
api_resources.Recipient.OBJECT_NAME: api_resources.Recipient,
api_resources.RecipientTransfer.OBJECT_NAME:
api_resources.RecipientTransfer,
Expand Down
65 changes: 65 additions & 0 deletions tests/api_resources/radar/test_value_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from __future__ import absolute_import, division, print_function

import stripe


TEST_RESOURCE_ID = 'rsl_123'


class TestValueList(object):
def test_is_listable(self, request_mock):
resources = stripe.radar.ValueList.list()
request_mock.assert_requested(
'get',
'/v1/radar/value_lists'
)
assert isinstance(resources.data, list)
assert isinstance(resources.data[0], stripe.radar.ValueList)

def test_is_retrievable(self, request_mock):
resource = stripe.radar.ValueList.retrieve(TEST_RESOURCE_ID)
request_mock.assert_requested(
'get',
'/v1/radar/value_lists/%s' % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.radar.ValueList)

def test_is_creatable(self, request_mock):
resource = stripe.radar.ValueList.create(
alias='alias',
name='name'
)
request_mock.assert_requested(
'post',
'/v1/radar/value_lists'
)
assert isinstance(resource, stripe.radar.ValueList)

def test_is_saveable(self, request_mock):
resource = stripe.radar.ValueList.retrieve(TEST_RESOURCE_ID)
resource.metadata['key'] = 'value'
resource.save()
request_mock.assert_requested(
'post',
'/v1/radar/value_lists/%s' % TEST_RESOURCE_ID
)

def test_is_modifiable(self, request_mock):
resource = stripe.radar.ValueList.modify(
TEST_RESOURCE_ID,
metadata={'key': 'value'}
)
request_mock.assert_requested(
'post',
'/v1/radar/value_lists/%s' % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.radar.ValueList)

def test_is_deletable(self, request_mock):
resource = stripe.radar.ValueList.retrieve(TEST_RESOURCE_ID)
resource.delete()
request_mock.assert_requested(
'delete',
'/v1/radar/value_lists/%s' % TEST_RESOURCE_ID
)
assert resource.deleted is True
45 changes: 45 additions & 0 deletions tests/api_resources/radar/test_value_list_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from __future__ import absolute_import, division, print_function

import stripe


TEST_RESOURCE_ID = 'rsli_123'


class TestValueListItem(object):
def test_is_listable(self, request_mock):
resources = stripe.radar.ValueListItem.list(value_list='rsl_123')
request_mock.assert_requested(
'get',
'/v1/radar/value_list_items'
)
assert isinstance(resources.data, list)
assert isinstance(resources.data[0], stripe.radar.ValueListItem)

def test_is_retrievable(self, request_mock):
resource = stripe.radar.ValueListItem.retrieve(TEST_RESOURCE_ID)
request_mock.assert_requested(
'get',
'/v1/radar/value_list_items/%s' % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.radar.ValueListItem)

def test_is_creatable(self, request_mock):
resource = stripe.radar.ValueListItem.create(
value_list='rsl_123',
value='value'
)
request_mock.assert_requested(
'post',
'/v1/radar/value_list_items'
)
assert isinstance(resource, stripe.radar.ValueListItem)

def test_is_deletable(self, request_mock):
resource = stripe.radar.ValueListItem.retrieve(TEST_RESOURCE_ID)
resource.delete()
request_mock.assert_requested(
'delete',
'/v1/radar/value_list_items/%s' % TEST_RESOURCE_ID
)
assert resource.deleted is True
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from tests.request_mock import RequestMock


MOCK_MINIMUM_VERSION = '0.35.0'
MOCK_MINIMUM_VERSION = '0.37.0'
MOCK_PORT = os.environ.get('STRIPE_MOCK_PORT', 12111)


Expand Down