Skip to content

Commit

Permalink
Add tests for qpc credentials
Browse files Browse the repository at this point in the history
Close #104
  • Loading branch information
elyezer committed Jan 3, 2018
1 parent 7dfa22f commit 4b61bc0
Show file tree
Hide file tree
Showing 9 changed files with 796 additions and 0 deletions.
1 change: 1 addition & 0 deletions camayoc/tests/qcs/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for quipucords' ``qpc`` command line interface."""
34 changes: 34 additions & 0 deletions camayoc/tests/qcs/cli/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Test utilities for quipucords' ``qpc`` tests."""
from io import BytesIO

import pexpect
import pytest

from camayoc.config import get_config


@pytest.fixture()
def qpc_server_config():
"""Read Camayoc's configuration file and configure qpc.
Both hostname and port must be available on the configuration file, for
example::
qpc:
hostname: localhost
port: 8000
"""
config = get_config()
hostname = config.get('qcs', {}).get('hostname')
port = config.get('qcs', {}).get('port')
if not all([hostname, port]):
raise ValueError(
'Both hostname and port must be defined under the qcs section on '
'the Camayoc\'s configuration file.')
command = 'qpc server config --host {} --port {}'.format(
hostname, port)
qpc_server_config = pexpect.spawn(command)
qpc_server_config.logfile = BytesIO()
assert qpc_server_config.expect(pexpect.EOF) == 0
qpc_server_config.close()
assert qpc_server_config.exitstatus == 0
Loading

0 comments on commit 4b61bc0

Please sign in to comment.