Skip to content

Commit

Permalink
rework api tests using pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
benmaddison committed Jul 6, 2018
1 parent 3438f78 commit 0a48cb7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 47 deletions.
54 changes: 54 additions & 0 deletions test/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (c) 2018 Workonline Communications (Pty) Ltd. All rights reserved.
#
# The contents of this file are licensed under the Apache License version 2.0
# (the "License"); you may not use this file except in compliance with the
# License.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""rptk API test cases."""

from __future__ import print_function
from __future__ import unicode_literals

import itertools
import os

import pytest

from rptk import RptkAPI


@pytest.fixture(scope="session")
def api():
"""Construct an API instance with the test config."""
config_file = os.path.join(os.path.dirname(__file__), 'tests.conf')
return RptkAPI(config_file=config_file)


@pytest.fixture(scope="session")
def posix():
"""Check whether we are on a POSIX system."""
return os.name == "posix"


def classmap(api):
"""Construct a cartesian product of the available classes."""
return itertools.product(api.query_class_loader.class_names,
api.format_class_loader.class_names)


class TestAPI(object):
"""Test cases for rptk python API."""

@pytest.mark.parametrize(("q", "f"), classmap(api()))
def test_api(self, api, posix, q, f):
"""Test rptk python API."""
if api.query_class_loader.get_class(name=q).posix_only and not posix:
pytest.skip("skipping posix only test")
api.update_opts(query=q, format=f)
result = api.query(test=True)
assert result
47 changes: 0 additions & 47 deletions test/test_cases.py

This file was deleted.

0 comments on commit 0a48cb7

Please sign in to comment.