Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/add pytest itde plugin #1

Merged
merged 20 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
type: int
jobs:
Release:
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
Nicoretti marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

Verify:
name: Tests
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- name: SCM Checkout
Expand Down
156 changes: 156 additions & 0 deletions pytest-itde/test/integration/pytest_itde_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import os
from inspect import cleandoc
from itertools import chain

import pytest

pytest_plugins = "pytester"


@pytest.fixture
def make_test_files():
def make(pytester, files):
pytester.makepyfile(**files)

return make


def _ids(params):
keys = (k for k in params.keys())
return next(keys)


default_version = "8.18.1"
default_version_only=pytest.mark.skipif(
"EXASOL_VERSION" in os.environ and os.environ["EXASOL_VERSION"] != default_version,
reason="""This test always uses default version of Exasol database. If
the current run of a matrix build uses a different version then executing
all tests requires to download two docker images in total. For Exasol
versions 8 and higher the size of the Docker Containers did drastically
increase which in turn causes error "no space left on device" in the GitHub Action Runners.""",
)


@default_version_only
@pytest.mark.slow
@pytest.mark.parametrize(
"files",
[
{
"test_smoke_test": cleandoc(
"""
def test_itde_smoke_test(itde):
# This smoke test just makes sure db spin up etc does not fail
assert True
"""
)
}], ids=_ids
)
def test_itde_smoke_test(make_test_files, pytester, files):
make_test_files(pytester, files)
result = pytester.runpytest()
assert result.ret == pytest.ExitCode.OK


@default_version_only
@pytest.mark.parametrize(
"files",
[
{
"test_exasol_settings": cleandoc(
"""
def test_default_settings_of_exasol(exasol_config):
assert exasol_config.host == 'localhost'
assert exasol_config.port == 8563
assert exasol_config.username == 'SYS'
assert exasol_config.password == 'exasol'
"""
)
},
{
"test_bucketfs_settings": cleandoc(
"""
def test_default_settings_of_bucketfs(bucketfs_config):
assert bucketfs_config.url == 'http://127.0.0.1:2580'
assert bucketfs_config.username == 'w'
assert bucketfs_config.password == 'write'
"""
)
},
{
"test_itde_settings": cleandoc(
f"""
def test_default_settings_of_itde(itde_config):
assert itde_config.db_version == '{default_version}'
assert set(itde_config.schemas) == set(('TEST', 'TEST_SCHEMA'))
"""
)
},
],
ids=_ids,
)
def test_default_settings_for_options(pytester, make_test_files, files):
make_test_files(pytester, files)
result = pytester.runpytest()
assert result.ret == pytest.ExitCode.OK


@pytest.mark.parametrize(
"files,cli_args",
[
(
{
"test_exasol_settings": cleandoc(
"""
def test_default_settings_of_exasol(exasol_config):
assert exasol_config.host == '127.0.0.1'
assert exasol_config.port == 7777
assert exasol_config.username == 'foo'
assert exasol_config.password == 'bar'
"""
)
},
{
"--exasol-port": 7777,
"--exasol-host": "127.0.0.1",
"--exasol-username": "foo",
"--exasol-password": "bar",
},
),
(
{
"test_bucketfs_settings": cleandoc(
"""
def test_default_settings_of_bucketfs(bucketfs_config):
assert bucketfs_config.url == 'https://127.0.0.1:7777'
assert bucketfs_config.username == 'user'
assert bucketfs_config.password == 'pw'
"""
)
},
{
"--bucketfs-url": "https://127.0.0.1:7777",
"--bucketfs-username": "user",
"--bucketfs-password": "pw",
},
),
(
{
"test_itde_settings": cleandoc(
"""
def test_default_settings_of_itde(itde_config):
assert itde_config.db_version == '7.1.0'
assert set(itde_config.schemas) == set(('TEST_FOO', 'TEST_BAR'))
"""
)
},
{"--itde-db-version": "7.1.0", "--itde-schemas": "TEST_FOO, TEST_BAR"},
),
],
ids=_ids,
)
def test_pass_options_via_cli(pytester, make_test_files, files, cli_args):
make_test_files(pytester, files)
args = chain.from_iterable(cli_args.items())
result = pytester.runpytest(*args)
assert result.ret == pytest.ExitCode.OK
Loading