Skip to content

Commit

Permalink
Merge pull request #500 from stripe/remi-add-radar-review
Browse files Browse the repository at this point in the history
Add support for the Review resource
  • Loading branch information
remi-stripe authored Nov 28, 2018
2 parents 6d0ab7e + ab1c5d0 commit 2a3ee55
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 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.37.0
- STRIPE_MOCK_VERSION=0.38.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/api_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from stripe.api_resources.recipient_transfer import RecipientTransfer
from stripe.api_resources.refund import Refund
from stripe.api_resources.reversal import Reversal
from stripe.api_resources.review import Review
from stripe.api_resources.sku import SKU
from stripe.api_resources.source import Source
from stripe.api_resources.source_transaction import SourceTransaction
Expand Down
14 changes: 14 additions & 0 deletions stripe/api_resources/review.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from __future__ import absolute_import, division, print_function

from stripe import util
from stripe.api_resources.abstract import ListableAPIResource


class Review(ListableAPIResource):
OBJECT_NAME = 'review'

def approve(self, idempotency_key=None, **params):
url = self.instance_url() + '/approve'
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request('post', url, params, headers))
return self
1 change: 1 addition & 0 deletions stripe/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def load_object_classes():
api_resources.reporting.ReportType.OBJECT_NAME:
api_resources.reporting.ReportType,
api_resources.Reversal.OBJECT_NAME: api_resources.Reversal,
api_resources.Review.OBJECT_NAME: api_resources.Review,
api_resources.sigma.ScheduledQueryRun.OBJECT_NAME:
api_resources.sigma.ScheduledQueryRun,
api_resources.SKU.OBJECT_NAME: api_resources.SKU,
Expand Down
34 changes: 34 additions & 0 deletions tests/api_resources/test_review.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from __future__ import absolute_import, division, print_function

import stripe


TEST_RESOURCE_ID = 'prv_123'


class TestReview(object):
def test_is_listable(self, request_mock):
resources = stripe.Review.list()
request_mock.assert_requested(
'get',
'/v1/reviews'
)
assert isinstance(resources.data, list)
assert isinstance(resources.data[0], stripe.Review)

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

def test_is_approveable(self, request_mock):
resource = stripe.Review.retrieve(TEST_RESOURCE_ID)
resource.approve()
request_mock.assert_requested(
'post',
'/v1/reviews/%s/approve' % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.Review)
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.37.0'
MOCK_MINIMUM_VERSION = '0.38.0'
MOCK_PORT = os.environ.get('STRIPE_MOCK_PORT', 12111)


Expand Down

0 comments on commit 2a3ee55

Please sign in to comment.