wrapAPI
Requests wrapper for API testing
Usage
conftest
conftest.py
import pytest
from wrapapi import Application, Settings
@pytest.fixture(scope='session')
def settings() -> Settings:
config = Settings()
config.base_url = 'http://localhost:5555'
config.headers['Autorization'] = 'Basic secret'
return config
@pytest.fixture(scope='session')
def client(settings) -> Application:
app = Application(settings)
client = app.create()
yield client
client.close()
@pytest.fixture(scope='function')
def app(client) -> Application:
yield client
client.report.build()
tests with pytest fixture
def test_main(app):
response = app.get('/api/main', status=200)
response.json.should.be.is_instance(list)
def test_main_item(app):
response = app.get('/api/main/666', status=200)
response.json.should.be.equal({'id': 666, 'name': 'test'})
TestCase
with TestSuite
from wrapapi import TestSuite
class TestExample(TestSuite):
def test_main(self):
response = self.app.get('/api/main', status=200)
response.json.should.be.is_instance(list)
def test_main_item(self):
response = self.app.get('/api/main/666', status=200)
response.json.should.be.equal({'id': 666, 'name': 'test'})
AssertionErrors
If we have any errors, raise exception with full request data:
E AssertionError:
E ===========================================================
E GET: http://localhost:5555/api/main/666
E -----------------------------------------------------------
E Status: 200
E Body: None
E Headers: {'Date': 'Wed, 27 Mar 2019 12:17:48 GMT', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Content-Length': '51'....}
E ===========================================================
E Not equal: {'id': 666, 'name': 'test'} == {'id': 1, 'name': 'test'}
E -> expected: {'id': 666, 'name': 'test'}
E -> current: {'id': 1, 'name': 'test'}
Metadata
Release files for wrapAPI 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wrapAPI-0.0.1.tar.gz | 6.7 kB | Without provenance | Details for wrapAPI-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wrapAPI-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for wrapAPI-0.0.1-py3-none-any.whl |
Total release size: 15.9 kB
Release files / wrapAPI-0.0.1.tar.gz
| Download URL | wrapAPI-0.0.1.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fac82fae31a38df6d21d4b403188918a107d9a6c395e71c9ee165e620e04a369
|
|
BLAKE2b-256 checksum How to use checksums |
a50519a251c4fbfee36323cd958ab17849eb6545bd91941ace946030589c2611
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / wrapAPI-0.0.1-py3-none-any.whl
| Download URL | wrapAPI-0.0.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30566d70b37a29e089636016e304dc4f6669704d616c21feaba3eb474fcbbbd7
|
|
BLAKE2b-256 checksum How to use checksums |
ca84bf5ef92950b84cfc344b0c50e5cc56a11e1e8a3deb0b3707187ca9527b6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for wrapAPI 0.0.1
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.