diff --git a/tests/unit/base/test_version.py b/tests/unit/base/test_version.py index 3cb11e3bed..69c0d9e515 100644 --- a/tests/unit/base/test_version.py +++ b/tests/unit/base/test_version.py @@ -12,9 +12,9 @@ def get_instance(self, payload): return payload -class VersionTestCase(IntegrationTestCase): +class StreamTestCase(IntegrationTestCase): def setUp(self): - super(VersionTestCase, self).setUp() + super(StreamTestCase, self).setUp() self.holodeck.mock(Response( 200, @@ -64,3 +64,17 @@ def test_stream_page_limit(self): messages = list(self.version.stream(self.page, page_limit=1)) self.assertEqual(len(messages), 2) + + +class VersionTestCase(IntegrationTestCase): + def test_fetch_redirect(self): + self.holodeck.mock(Response( + 307, + '{"redirect_to": "some_place"}' + ), Request(url='https://messaging.twilio.com/v1/Deactivations')) + response = self.client.messaging.v1.fetch( + method='GET', + uri='/Deactivations' + ) + + self.assertIsNotNone(response) diff --git a/twilio/base/version.py b/twilio/base/version.py index 8efcbee8a3..a598e76b3b 100644 --- a/twilio/base/version.py +++ b/twilio/base/version.py @@ -80,7 +80,8 @@ def fetch(self, method, uri, params=None, data=None, headers=None, auth=None, ti allow_redirects=allow_redirects, ) - if response.status_code < 200 or response.status_code >= 300: + # Note that 3XX response codes are allowed for fetches. + if response.status_code < 200 or response.status_code >= 400: raise self.exception(method, uri, response, 'Unable to fetch record') return json.loads(response.text)