Last active
April 5, 2017 14:24
-
-
Save tarekziade/e785100829c4f78e5a3c82ca14406697 to your computer and use it in GitHub Desktop.
poutine test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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