Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
import recurly
# Mock everything out unless we have an API key.
try:
api_key = os.environ['RECURLY_API_KEY']
except KeyError:
# Mock everything out.
recurly.API_KEY = 'apikey'
self.test_id = 'mock'
else:
recurly.API_KEY = api_key
self.mock_request = self.noop_mock_request
self.mock_sleep = self.noop_mock_sleep
self.test_id = datetime.now().strftime('%Y%m%d%H%M%S')
# Update our endpoint if we have a different test host.
try:
recurly_host = os.environ['RECURLY_HOST']
except KeyError:
pass
else:
recurly.BASE_URI = 'https://%s/v2/' % recurly_host
logging.basicConfig(level=logging.INFO)
logging.getLogger('recurly').setLevel(logging.DEBUG)
def setUp(self):
import recurly
# Mock everything out unless we have an API key.
try:
api_key = os.environ['RECURLY_API_KEY']
except KeyError:
# Mock everything out.
recurly.API_KEY = 'apikey'
self.test_id = 'mock'
else:
recurly.API_KEY = api_key
self.mock_request = self.noop_mock_request
self.mock_sleep = self.noop_mock_sleep
self.test_id = datetime.now().strftime('%Y%m%d%H%M%S')
# Update our endpoint if we have a different test host.
try:
recurly_host = os.environ['RECURLY_HOST']
except KeyError:
pass
else:
recurly.BASE_URI = 'https://%s/v2/' % recurly_host
logging.basicConfig(level=logging.INFO)
import recurly
from django.conf import settings
recurly.API_KEY = settings.RECURLY_API_KEY
if hasattr(settings, 'RECURLY_JS_PRIVATE_KEY'):
recurly.js.PRIVATE_KEY = settings.RECURLY_JS_PRIVATE_KEY
def generate_signature(self):
# workaround for http://bugs.python.org/issue5285, map unicode to strings
settings = get_settings()
recurly.API_KEY = str(settings.recurly_api_key)
recurly.js.PRIVATE_KEY = str(settings.recurly_private_key)
plan_code = str(settings.recurly_plan_code)
# Set a default currency for your API requests
recurly.DEFAULT_CURRENCY = 'USD'
return recurly.js.sign({'subscription': {'plan_code': plan_code}})
def recurly(self):
import recurly
recurly.SUBDOMAIN = os.environ.get('RECURLY_SUBDOMAIN')
recurly.API_KEY = os.environ.get('RECURLY_API_KEY')
return recurly