Skip to content

Instantly share code, notes, and snippets.

@tarekziade
Last active April 5, 2017 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarekziade/e785100829c4f78e5a3c82ca14406697 to your computer and use it in GitHub Desktop.
Save tarekziade/e785100829c4f78e5a3c82ca14406697 to your computer and use it in GitHub Desktop.
poutine test
import asyncio
import configparser
import pytest
from smwogger import API
@pytest.fixture
def conf():
config = configparser.ConfigParser()
config.read('manifest.ini')
return config
@pytest.fixture(scope="module")
def event_loop():
return asyncio.get_event_loop()
@pytest.fixture(scope="module")
def api(event_loop):
return API('__api__.json', loop=event_loop)
@pytest.mark.asyncio
async def test_version(conf, env, api):
res = await api.__version__()
data = await res.json()
expected_fields = ['version', 'source', 'name', 'build', 'commit']
# First, make sure that data only contains fields we expect
for key in data:
assert key in expected_fields
# Then make the we only have the expected fields in the data
for field in expected_fields:
assert field in data
@pytest.mark.asyncio
async def test_heartbeat(conf, env, api):
res = await api.__heartbeat__()
data = await res.json()
expected_fields = ['permission', 'cache', 'storage']
# First, make sure that data only contains fields we expect
for key in data:
assert key in expected_fields
# Then make the we only have the expected fields in the data
for field in expected_fields:
assert field in data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment