diff --git a/.travis.yml b/.travis.yml index 27a4d032a..f706036a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/stripe/__init__.py b/stripe/__init__.py index 46eeaa320..4a1779b52 100644 --- a/stripe/__init__.py +++ b/stripe/__init__.py @@ -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 diff --git a/stripe/api_resources/radar/__init__.py b/stripe/api_resources/radar/__init__.py new file mode 100644 index 000000000..7dc2f7ed2 --- /dev/null +++ b/stripe/api_resources/radar/__init__.py @@ -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 diff --git a/stripe/api_resources/radar/value_list.py b/stripe/api_resources/radar/value_list.py new file mode 100644 index 000000000..7d9c44321 --- /dev/null +++ b/stripe/api_resources/radar/value_list.py @@ -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' diff --git a/stripe/api_resources/radar/value_list_item.py b/stripe/api_resources/radar/value_list_item.py new file mode 100644 index 000000000..8cb1c60f8 --- /dev/null +++ b/stripe/api_resources/radar/value_list_item.py @@ -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' diff --git a/stripe/util.py b/stripe/util.py index 83a100a03..533462e38 100644 --- a/stripe/util.py +++ b/stripe/util.py @@ -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, diff --git a/tests/api_resources/radar/test_value_list.py b/tests/api_resources/radar/test_value_list.py new file mode 100644 index 000000000..d5dbd13f1 --- /dev/null +++ b/tests/api_resources/radar/test_value_list.py @@ -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 diff --git a/tests/api_resources/radar/test_value_list_item.py b/tests/api_resources/radar/test_value_list_item.py new file mode 100644 index 000000000..7677e9d3a --- /dev/null +++ b/tests/api_resources/radar/test_value_list_item.py @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index 14bc6ca09..1f052740f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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)