Skip to main content

Mock library for the airtable python client

Project description

A mock library to help test Python code accessing Airtable using the Python library.

It keeps tables in RAM and can do basic operations.

Installation

The easiest way is using pip:

pip install airtablemock

Usage

In your test, you patch the whole airtable library:

import unittest

import airtablemock

import mycode


@airtablemock.patch(mycode.__name__ + '.airtable')
class TestMyCode(unittest.TestCase):

  def test_foo():
    # This is a client for the base "baseID", it will not access the real
    # Airtable service but only the mock one which keeps data in RAM.
    client = airtablemock.Airtable('baseID', 'apiKey')

    # Populate the table.
    client.create('table-foo', {'field1': 1, 'field2': 'two'})

    # Run your code that uses Airtable, it should transparently uses the table
    # above.
    mycode.run()

    # Access the table again to check if anything was modified.
    records = client.get('table-foo')
    

Release

To create a new release of airtablemock, tag the Git repo and run:

python setup.py sdist bdist_wheel
twine upload dist/airtablemock-*

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for airtablemock, version 0.0.11
Filename, size File type Python version Upload date Hashes
Filename, size airtablemock-0.0.11-py2.py3-none-any.whl (6.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size airtablemock-0.0.11.tar.gz (9.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page