Skip to main content

python library to perform assertion on files

Project description

qload : better assertion on files

qload is a library to load or extract content of a file to perform assertion in automatic tests without boilerplate. It support file from filesystem, ftp, s3, ...

Benefits

  • oneliner to assert on the content of a file
  • useful differential when the test fails thanks to subpart extraction
  • support for the most common formats (yaml, csv, json, txt)
  • support for multiple file systems and protocols (local, ftp, s3)
  • rich expression engine to extract part of a file (regexp for text and jmespath for csv, json and yaml to improve differential)

Gettings started

pip install qload

Usage

import qload

assert 'database_url: postgresql://127.0.0.1:5432/postgres' in qload.text('file.txt')
assert qload.text('file.txt', expression='Hello .*') == 'Hello Fabien'

assert qload.json('file.json') == {}
assert qload.json('s3://mybucket/file1.json') == {}
assert qload.json('file.json', expression='$.id') == ''
assert len(qload.json('file.json', expression='$.id')) == 4

assert qload.yaml('file.yml')  == {}
assert qload.yaml('file.yml', expression='$.id')  == ''

assert qload.csv('file.csv', expression='[*].Account') == ['ALK', 'BTL', 'CKL']
assert qload.csv('file.csv', expression='[*].Account')[0] == 'ALK'

assert qload.parquet('file.parquet', expression='[*].Account')[0] == 'ALK'

assert qload.ftp(host='localhost', port=21, login='admin', password='admin').csv(path='dir/file.csv', expression='') == []
assert qload.s3(bucket='bucket', aws_access_key_id='', aws_secret_access_key='', region_name='eu-west-1', endpoint_url='http://localhost:9090').json(path='dir/file.csv') == {}


assert qload.isfile('file.json') is True
assert qload.s3(bucket='bucket').isfile('file.json') is True

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

qload-1.0.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

qload-1.0.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file qload-1.0.3.tar.gz.

File metadata

  • Download URL: qload-1.0.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-35-generic

File hashes

Hashes for qload-1.0.3.tar.gz
Algorithm Hash digest
SHA256 415bde98c37d47c756ba07aaeb45f148de0fb22ccf1b1367a2ed8d94373049eb
MD5 7d609f146094e1a8c0431e9bf3ec58d7
BLAKE2b-256 d1d199d58ce87873ac39400f39f50d4846a69cdfa2634cc47c3ba4344b66a263

See more details on using hashes here.

File details

Details for the file qload-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: qload-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-35-generic

File hashes

Hashes for qload-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af38eafd0ec0bfbf439f5d2a6db057f2255d339313afa9aef8517faf10d6188f
MD5 f5b568e2230322d487ef2a097e5696fa
BLAKE2b-256 afbf27c829349cd42b389a4e5051c3d89348d509d8ac989be79cb2e3124f23d6

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