跳转到主要内容

用于Airtable Python客户端的Mock库

项目描述

一个Mock库,帮助测试使用Python库访问Airtable的Python代码。

它将表存储在RAM中,并能执行基本操作。

安装

最简单的方法是使用pip

pip install airtablemock

使用方法

在您的测试中,修补整个airtable库

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')
    

发布

要创建airtablemock的新版本,对Git仓库进行标记并运行

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

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

airtablemock-0.0.11.tar.gz (9.5 kB 查看哈希值)

上传时间 源代码

构建分发

airtablemock-0.0.11-py2.py3-none-any.whl (6.7 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持