Skip to content
Snippets Groups Projects
Commit 543b30c4 authored by roadscape's avatar roadscape
Browse files

get_state tests

parent 79002436
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ aiomysql = "*"
"pytest-cov" = "*"
"pytest-docker" = "*"
"pytest-pylint" = "*"
"pytest-asyncio" = "*"
"pytest-console-scripts" = "*"
"yapf" = "*"
"autopep8" = "*"
......@@ -10,14 +10,15 @@ def _generate(infile):
for line in open(infile, 'r'):
line = line.strip()
if line[0:4] == 'def ' and line[0:5] != 'def _':
m = re.match(r'^def\s([^\(]+)\(([^\)]*)\):$', line)
assert m and m[1], "`%s` no match" % line
method = m[1]
args = m[2]
m = re.match(r'^(async )?def\s([^_\(][^\(]+)\(([^\)]*)\):$', line)
if m:
isasync = bool(m[1])
method = m[2]
args = m[3]
methods.append(method)
stub = "def test_%s():\n assert %s(%s) == expected" % (method, method, args)
stub = "def test_%s():\n assert %s%s(%s) == expected" % (
method, 'await ' if isasync else '', method, args)
stubs.append(stub)
outfile = open('tests/test_' + '_'.join(path[1:]) + '.py', 'w')
......
......@@ -10,6 +10,7 @@ tests_require = [
'pytest',
'pytest-cov',
'pytest-pylint',
'pytest-asyncio',
'pytest-console-scripts',
'git-pylint-commit-hook',
'pep8',
......@@ -20,7 +21,7 @@ tests_require = [
setup(
name='hivemind',
version='0.0.1',
description='Community consensus layer for the Steem blockchain',
description='Developer-friendly microservice powering social networks on the Steem blockchain.',
long_description=open('README.md').read(),
packages=find_packages(exclude=['scripts']),
setup_requires=['pytest-runner'],
......
import pytest
from hive.server.condenser_api.get_state import get_state
@pytest.mark.asyncio
async def test_get_state():
ret = await get_state('/trending')
assert 'discussion_idx' in ret
assert await get_state('trending')
assert await get_state('promoted')
assert await get_state('created')
assert await get_state('hot')
assert await get_state('@test-safari')
assert await get_state('@test-safari/feed')
assert await get_state('@test-safari/comments')
assert await get_state('@test-safari/recent-replies')
assert await get_state('spam/@test-safari/1ncq2-may-spam')
assert await get_state('trending/blockchain')
assert await get_state('tags')
with pytest.raises(AssertionError):
await get_state('trending/blockchain/xxx')
with pytest.raises(AssertionError):
await get_state('tags/xxx')
with pytest.raises(Exception):
await get_state('witnesses')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment