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

add condenser_api disc tests and test conf

parent 63111a5c
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import configargparse
class Conf():
""" Manages sync/server configuration via args, ENVs, and hive.conf. """
_args = None
_env = None
@classmethod
def init_argparse(cls, ignore_unknown=False):
......@@ -48,6 +49,15 @@ class Conf():
root.setLevel(cls.log_level())
root.info("loaded configuration:\n%s", parser.format_values())
@classmethod
def init_test(cls):
"""Initialize hive config for testing."""
if cls._args:
assert cls._env == 'test'
return # config already read
cls._env = 'test'
cls.init_argparse(ignore_unknown=True)
@classmethod
def init_config(cls, config):
"""Initialize config directly (do not parse ENV/cli/conf)."""
......
......@@ -38,7 +38,7 @@ async def get_following(account: str, start: str, follow_type: str, limit: int):
async def get_follow_count(account: str):
"""Get follow count stats. (EOL)"""
count = cursor.get_follow_counts(account)
count = cursor.get_follow_counts(valid_account(account))
return dict(account=account,
following_count=count['following'],
follower_count=count['followers'])
......
from hive.conf import Conf
Conf.init_test()
......@@ -4,21 +4,6 @@ from hive.server.condenser_api.get_state import get_state
from hive.server.condenser_api.tags import get_trending_tags
from hive.server.condenser_api.call import call
#from hive.server.condenser_api import methods as condenser_api
#condenser_api.get_followers,
#condenser_api.get_following,
#condenser_api.get_follow_count,
#condenser_api.get_content,
#condenser_api.get_content_replies,
#condenser_api.get_discussions_by_trending,
#condenser_api.get_discussions_by_hot,
#condenser_api.get_discussions_by_promoted,
#condenser_api.get_discussions_by_created,
#condenser_api.get_discussions_by_blog,
#condenser_api.get_discussions_by_feed,
#condenser_api.get_discussions_by_comments,
#condenser_api.get_replies_by_last_update,
@pytest.mark.asyncio
async def test_get_state():
ret = await get_state('/trending')
......
#pylint: disable=missing-docstring,invalid-name
import pytest
from hive.server.condenser_api.methods import (
get_followers,
get_following,
get_follow_count,
get_content,
get_content_replies,
get_discussions_by_trending,
get_discussions_by_hot,
get_discussions_by_promoted,
get_discussions_by_created,
get_discussions_by_blog,
get_discussions_by_feed,
get_discussions_by_comments,
get_replies_by_last_update,
)
@pytest.mark.asyncio
async def test_get_followers():
assert await get_followers('test-safari', '', 'blog', 10)
@pytest.mark.asyncio
async def test_get_following():
assert await get_following('test-safari', '', 'blog', 10)
@pytest.mark.asyncio
async def test_get_follow_count():
assert await get_follow_count('test-safari')
@pytest.mark.asyncio
async def test_get_content():
post = await get_content('test-safari', 'december-spam')
assert post
assert post['author'] == 'test-safari'
@pytest.mark.asyncio
async def test_get_content_replies():
replies = await get_content_replies('test-safari', 'december-spam')
assert replies
assert len(replies) > 3
assert replies[0]['author']
@pytest.mark.asyncio
async def test_nested_query_compat():
params = dict(start_author='', start_permlink='', limit=10, tag='life', truncate_body=0)
ret1 = await get_discussions_by_trending(**params)
arg1 = [params]
ret2 = await get_discussions_by_trending(*arg1)
assert ret1 == ret2
@pytest.mark.asyncio
async def test_get_discussions_by_trending():
assert await get_discussions_by_trending(
start_author='', start_permlink='', limit=20, tag='', truncate_body=0)
@pytest.mark.asyncio
async def test_get_discussions_by_hot():
assert await get_discussions_by_hot(
start_author='', start_permlink='', limit=20, tag='', truncate_body=0)
@pytest.mark.asyncio
async def test_get_discussions_by_promoted():
assert await get_discussions_by_promoted(
start_author='', start_permlink='', limit=20, tag='', truncate_body=0)
@pytest.mark.asyncio
async def test_get_discussions_by_created():
assert await get_discussions_by_created(
start_author='', start_permlink='', limit=20, tag='', truncate_body=0)
@pytest.mark.asyncio
async def test_get_discussions_by_blog():
assert await get_discussions_by_blog(
tag='test-safari', start_author='', start_permlink='', limit=20, truncate_body=0)
@pytest.mark.asyncio
async def test_get_discussions_by_feed():
assert await get_discussions_by_feed(
tag='test-safari', start_author='', start_permlink='', limit=20, truncate_body=0)
@pytest.mark.asyncio
async def test_get_discussions_by_comments():
assert await get_discussions_by_comments(
start_author='test-safari',
start_permlink='',
limit=20,
truncate_body=0)
@pytest.mark.asyncio
async def test_get_replies_by_last_update():
assert await get_replies_by_last_update(
start_author='test-safari',
start_permlink='',
limit=20,
truncate_body=0)
from hive.conf import Conf
Conf.init_test()
......@@ -4,9 +4,6 @@ import pytest
from hive.steem.client import SteemClient
from hive.utils.normalize import parse_time
from hive.conf import Conf
Conf.init_argparse(ignore_unknown=True)
def test_instance():
assert isinstance(SteemClient.instance(), SteemClient)
......
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