Skip to main content

mocurly

Build Status Coverage Status Documentation Status

Mocurly is a library that mocks the recurly python client so that you can easily write tests for applications that use the recurly python client.

Full documentation is available at readthedocs.

Overview

Mocurly acts as a mock backend for the recurly client, allowing you to use the recurly python client AS IS. This means that all your code that uses the recurly python client and targets recurly objects will all work as you would expect. Best of all: you can use the recurly python client to setup the test environment!

For example, suppose you had a simple function in your app that lists all the users in recurly, and counts them:

import recurly
recurly.API_KEY = 'foo'
recurly.SUBDOMAIN = 'bar'

def count_recurly_accounts():
    return len(recurly.Account.all())

With mocurly, you can test the above code like so:

import recurly
recurly.API_KEY = 'foo'
recurly.SUBDOMAIN = 'bar'
from mocurly import mocurly
from count_module import count_recurly_accounts

@mocurly
def test_count_recurly_accounts():
    for i in range(10):
        recurly.Account(account_code=str(i)).save()
    assert count_recurly_accounts() == 10

Within the decorator context, all calls to recurly are captured by mocurly, which keeps the state in memory for the duration of the context. No actual web calls are made, allowing you to test your recurly code without worrying about existing context or internet connections.

Usage

You can use mocurly as a decorator, context manager, or manually.

Decorator

@mocurly
def test_count_recurly_accounts():
    for i in range(10):
        recurly.Account(account_code=str(i)).save()
    assert count_recurly_accounts() == 10

Context Manager

def test_count_recurly_accounts():
    with mocurly():
        for i in range(10):
            recurly.Account(account_code=str(i)).save()
        assert count_recurly_accounts() == 10

Manual

def test_count_recurly_accounts():
    mocurly_ = mocurly()
    mocurly_.start()

    for i in range(10):
        recurly.Account(account_code=str(i)).save()
    assert count_recurly_accounts() == 10

    mocurly_.stop()

Install

$ pip install mocurly

Metadata

Release files for mocurly 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mocurly 0.2.3
File Size Uploaded Provenance Actions
mocurly-0.2.3.tar.gz 20.0 kB Without provenance Details for mocurly-0.2.3.tar.gz

Release files / mocurly-0.2.3.tar.gz

Download URL mocurly-0.2.3.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a90687e4d983193495d4766f205827bcca974cafd3e0c7786eed329b515df955
BLAKE2b-256 checksum
How to use checksums
f5216983d37bdc9698b370523521364ba2125f24124ff97070a8fbee00f8f8db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for mocurly 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page