Example #1
0
#!/usr/bin/env python
'''Test Config class

tox is recommented for running this test file.
For manual run:
    pip install -rtests/test_requirements.txt
    python -m pytest tests/test_odict.py
'''
from os import environ
from os.path import dirname, abspath
import sys
sys.path.insert(0, dirname(abspath(__file__)))
from loadconfig.lib import addpath
addpath(__file__, parent=True)

from loadconfig import Config, Odict
from loadconfig.lib import tempfile


def test_list_substitution():
    d = Odict('''\
            name:  &dancer
              - Zeela
              - Kim
            team:
              *dancer
            ''')
    assert '{name: [Zeela, Kim], team: [Zeela, Kim]}' == repr(d)


def test_unexistent_include_config():
#!/usr/bin/env python
'''Test sphinxserve.

Tox is recommented for running this pytest.
'''
import gevent.monkey
gevent.monkey.patch_all()

# Add project directory into sys.path and cd into it
from loadconfig.lib import addpath
from os import chdir
PROJECT_PATH = addpath(__file__, parent=True)
chdir(PROJECT_PATH)

from gevent import joinall, sleep, spawn
from loadconfig import Config
from loadconfig.lib import tempdir, capture_stream
from multiprocessing import Process
from pytest import yield_fixture
from requests import get
from sphinxserve import main
from sphinxserve.lib import check_host, fs_event_ctx, Ret, Timeout


@yield_fixture
def serve_ctx():
    '''Functional serve context for testing core sphinxserve functionality'''

    c = Config('''\
        app: sphinxserve
        host: localhost