Skip to content
This repository was archived by the owner on Feb 4, 2026. It is now read-only.
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
15 changes: 12 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
[bumpversion]
current_version = 0.2.3
parse = (?P<major>\d+)\.(?P<minor>.*)\.(?P<patch>.*)
serialize = {major}.{minor}.{patch}
current_version = 0.2.4-dev0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}-{release}{build}
{major}.{minor}.{patch}

[bumpversion:part:release]
optional_value = prod
first_value = dev
values =
dev
prod

[bumpversion:file:setup.py]

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# The short X.Y version.
version = '0.2'
# The full version, including alpha/beta/rc tags.
release = '0.2.3'
release = '0.2.4-dev0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion mocurly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from .errors import *
from .backend import *

__version__ = '0.2.3'
__version__ = '0.2.4-dev0'
17 changes: 9 additions & 8 deletions mocurly/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
Exposes the main mocurly class which is the gateway into setting up the mocurly
context.
"""
import recurly
import re
import ssl
import functools
from six.moves.urllib.parse import urlparse, parse_qs, unquote
import re

import recurly
from httpretty import HTTPretty
from six.moves.urllib.parse import parse_qs, unquote, urlparse

from .utils import deserialize
from .errors import ResponseError
from .backend import clear_backends
from .errors import ResponseError
from .utils import deserialize


class mocurly(object):
Expand Down Expand Up @@ -260,11 +260,12 @@ def __init__(self, mocurly_instance):

def __call__(self, func):
def wrapped(request, uri, headers, **kwargs):
error_response_body = 'The read operation timed out'
# If we want to timeout the request, timeout, but only if we aren't
# going to allow the POST
if (self.mocurly_instance.should_timeout(request) and
not self.mocurly_instance.should_timeout_successful_post(request)):
raise ssl.SSLError('The read operation timed out')
return 502, headers, error_response_body

try:
return_val = func(request, uri, headers, **kwargs)
Expand All @@ -275,7 +276,7 @@ def wrapped(request, uri, headers, **kwargs):
return exc.status_code, headers, exc.response_body

if self.mocurly_instance.should_timeout_successful_post(request):
raise ssl.SSLError('The read operation timed out')
return 502, headers, error_response_body

return return_val
return wrapped
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
httpretty>=0.8,<=0.8.10
recurly>=2.2.23
httpretty>=0.9.4
recurly>=2.9.0,<3.0.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will require regression testing in the @15five/provisioning-payment-squad . We'll need to get a ticket set up for that.

jinja2
six
pytz
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tox
sphinx
bumpversion
iso8601
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
name='mocurly',
packages=find_packages(exclude=("tests", "tests.*")),
package_data={'mocurly': ['templates/*.xml']},
version='0.2.3',
version='0.2.4-dev0',
description='A library that allows your python tests to easily mock out the recurly library',
long_description=open('README.rst').read(),
author='Yoriyasu Yano',
author_email='yoriy@captricity.com',
url='https://github.com/Captricity/mocurly',
download_url='https://github.com/Captricity/mocurly/tarball/v0.2.3',
download_url='https://github.com/Captricity/mocurly/tarball/v0.2.4-dev0',
keywords = ['testing'],
install_requires=install_requires,
test_suite='tests'
Expand Down
15 changes: 8 additions & 7 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import unittest
import ssl
import recurly
recurly.API_KEY = 'blah'

import mocurly
import mocurly.backend
import recurly

recurly.API_KEY = 'blah'


class TestCore(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -58,7 +59,7 @@ def test_timeout(self):
mocurly_.start_timeout()

self.assertFalse(mocurly.backend.accounts_backend.has_object(self.base_account_data['account_code']))
self.assertRaises(ssl.SSLError, recurly.Account(**self.base_account_data).save)
self.assertRaises(recurly.errors.BadGatewayError, recurly.Account(**self.base_account_data).save)
self.assertFalse(mocurly.backend.accounts_backend.has_object(self.base_account_data['account_code']))

mocurly_.stop_timeout()
Expand All @@ -76,7 +77,7 @@ def test_timeout_successful_post(self):
mocurly_.start_timeout_successful_post()

self.assertFalse(mocurly.backend.accounts_backend.has_object(self.base_account_data['account_code']))
self.assertRaises(ssl.SSLError, recurly.Account(**self.base_account_data).save)
self.assertRaises(recurly.errors.BadGatewayError, recurly.Account(**self.base_account_data).save)
self.assertTrue(mocurly.backend.accounts_backend.has_object(self.base_account_data['account_code']))

mocurly_.stop_timeout_successful_post()
Expand All @@ -101,7 +102,7 @@ def timeout_filter(request):
self.assertFalse(mocurly.backend.accounts_backend.has_object(self.base_account_data['account_code']))
recurly.Account(**self.base_account_data).save()
self.assertTrue(mocurly.backend.accounts_backend.has_object(self.base_account_data['account_code']))
self.assertRaises(ssl.SSLError, recurly.Account.get, self.base_account_data['account_code'])
self.assertRaises(recurly.errors.BadGatewayError, recurly.Account.get, self.base_account_data['account_code'])

mocurly_.stop_timeout()

Expand All @@ -126,7 +127,7 @@ def timeout_filter(request):

self.assertEqual(len(mocurly.backend.transactions_backend.datastore), 0)
new_transaction = recurly.Transaction(account=new_account, amount_in_cents=20, currency='USD')
self.assertRaises(ssl.SSLError, new_transaction.save)
self.assertRaises(recurly.errors.BadGatewayError, new_transaction.save)
self.assertEqual(len(mocurly.backend.transactions_backend.datastore), 1)

mocurly_.stop_timeout_successful_post()
Expand Down