Skip to main content

No project description provided

Project description

Pytest Web3 Data

PyPI - Version PyPI - Python Version


A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution.

Table of Contents

Installation

pip install pytest-web3-data

Usage

Let's say we want to store our testing data at test/data/*.

Optionally, first add test/data/ to .gitignore.

Create example test data:

mkdir -p test/data/staging/
echo 'hello world!' > ./test/data/staging/hello.txt

Upload the data to the InterPlanetary File System (IPFS).

One option is to use web3.storage. Install Node/NPM, and install the w3 CLI:

npm install --location=global @web3-storage/w3

The set your upload token from https://web3.storage:

w3 token
# Paste in token from the web UI

Upload the testing data to IPFS:

w3 put ./test/data/staging --name pytest-web3-data-example --hidden --no-wrap

This outputs a reference to the Content Identifier (CID), e.g.:

# Packed 1 file (0.0MB)
# bafybeigvfmtttajzj5no3jt2xavkdncxy3xapw3rndvoxmao72vhwy4osu
⁂ Stored 1 file
⁂ https://w3s.link/ipfs/bafybeigvfmtttajzj5no3jt2xavkdncxy3xapw3rndvoxmao72vhwy4osu

When we create a test, e.g.:

# content of test_usage.py
def test_usage(web3_data):
    assert web3_data.exists()
    assert (web3_data / 'hello.txt').read_text() == "hello world!\n"

We can reference our CID either with a flag:

pytest --web3-data-dir=test/data/bafybeigvfmtttajzj5no3jt2xavkdncxy3xapw3rndvoxmao72vhwy4osu

or in the pytest.ini file:

# content of pytest.ini
[pytest]
web3_data_dir = test/data/bafybeigvfmtttajzj5no3jt2xavkdncxy3xapw3rndvoxmao72vhwy4osu

Enjoy! 😊

License

pytest-web3-data is distributed under the terms of the MIT license.

Project details


Download files

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

Source Distribution

pytest_web3_data-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

pytest_web3_data-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_web3_data-0.1.0.tar.gz.

File metadata

  • Download URL: pytest_web3_data-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.0

File hashes

Hashes for pytest_web3_data-0.1.0.tar.gz
Algorithm Hash digest
SHA256 afdffdd5e4604b4981b363315b70c20aceaf46a0589951f4fda2fd01efe50cf0
MD5 4e57bceb84b5061f68851eda9a00252a
BLAKE2b-256 c5573496458af3d59913de46db2acda5f477f39cac943714f9852d0801f4b0d5

See more details on using hashes here.

File details

Details for the file pytest_web3_data-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_web3_data-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dce61a64405bdaf26d1118c4b4168630f25426fd54cc79a721ee52b9d40f83d7
MD5 f5d3dca719c65eb18d7e077582be6c45
BLAKE2b-256 00261c4b6cf9e3fe3a06594acaabb7582a5874c47de1c152557e2e40d958833c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page