Skip to content

Commit

Permalink
#43 Created slc plugin (#46)
Browse files Browse the repository at this point in the history
* #43 prepared pytest-slc project

* #43 Created pytest_slc project

* Restored pytest-backend/noxconfig.py

* #43 Added pytest-slc to the CD workflow

* #43 set Python 3.10 in the github workflow

* #43 set Python 3.10 in the github workflow

* #43 Fixed wrong usage of connection parameters

* #43 Fixed the test

* #43 Fixed the test

* #43 Fixed the test
  • Loading branch information
ahsimb authored Aug 15, 2024
1 parent c136825 commit 418c713
Show file tree
Hide file tree
Showing 17 changed files with 2,879 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/actions/pytest-plugins-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
python-version:
description: 'Python version to use'
required: true
default: 3.9
default: "3.10"

poetry-version:
description: 'Poetry version to use'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
default: 'pytest-saas'
type: choice
options:
- "pytest-slc"
- "pytest-backend"
- "pytest-saas"
- "pytest-itde"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Whether you're looking to use database interactions, enhance test reporting, or
| `pytest-exasol-itde` | Fixture to enable simple usage with Exasol's project [ITDE](https://github.com/exasol/integration-test-docker-environment) | [pytest-exasol-itde](https://pypi.org/project/pytest-exasol-itde/) |
| `pytest-exasol-saas` | Fixture to enable simple usage with Exasol's project [saas-api-python](https://github.com/exasol/saas-api-python/) | [pytest-exasol-saas](https://pypi.org/project/pytest-exasol-saas/) |
| `pytest-exasol-backend` | Fixture aggregating functionality of both of the above plugins | [pytest-exasol-backend](https://pypi.org/project/pytest-exasol-backend/) |
| `pytest-exasol-slc` | Fixture for uploading a script language container | [pytest-exasol-slc](https://pypi.org/project/pytest-exasol-slc/) |


## Installation
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECTS := "pytest-backend pytest-saas pytest-itde"
PROJECTS := "pytest-slc pytest-backend pytest-saas pytest-itde"

# Default target
default:
Expand Down
1 change: 1 addition & 0 deletions pytest-slc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.html-documentation
28 changes: 28 additions & 0 deletions pytest-slc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# pytest-exasol-slc Plugin

The `pytest-exasol-slc` plugin provides a pytest fixture for uploading a script language container
into the database. The fixture is backend agnostic. It runs for the selected backends
(see the documentation for the `pytest-exasol-backend` plugin).

## Installation

The pytest-exasol-slc plugin can be installed using pip:

```shell
pip install pytest-exasol-slc
```

## Usage in Tests

Below is an example of a test that requires a script language container to be uploaded into the database.
Note, that by default this test will run twice - once for each backend.

```python
import pyexasol

def test_something_with_slc(upload_slc, container_file_path, language_alias):

upload_slc(container_file_path=container_file_path, language_alias=language_alias)

# Now run the actual test
```
14 changes: 14 additions & 0 deletions pytest-slc/doc/changes/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changes

* [unreleased](unreleased.md)
* [0.1.0](changes_0.1.0.md)

<!--- This MyST Parser Sphinx directive is necessary to keep Sphinx happy. We need list here all release letters again, because release droid and other scripts assume Markdown --->
```{toctree}
---
hidden:
---
unreleased
changes_0.1.0
```
9 changes: 9 additions & 0 deletions pytest-slc/doc/changes/changes_0.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 0.1.0 - 2024-08-15

## Summary

🚀 Initial Release of the pytest-exasol-slc Plugin

## Feature

* #37: Added the pytest-slc project
1 change: 1 addition & 0 deletions pytest-slc/doc/changes/unreleased.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Unreleased
25 changes: 25 additions & 0 deletions pytest-slc/exasol/pytest_slc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import annotations
from typing import Callable
from pathlib import Path
import pytest

import pyexasol
import exasol.bucketfs as bfs
from exasol.python_extension_common.deployment.language_container_deployer import LanguageContainerDeployer


@pytest.fixture(scope="session")
def upload_slc(backend_aware_database_params,
backend_aware_bucketfs_params) -> Callable[[str | Path, str, str], None]:

def func(container_file_path: str | Path,
language_alias: str,
bucketfs_path: str = ''):
pyexasol_connection = pyexasol.connect(**backend_aware_database_params)
bucketfs_path = bfs.path.build_path(**backend_aware_bucketfs_params, path=bucketfs_path)
deployer = LanguageContainerDeployer(pyexasol_connection=pyexasol_connection,
bucketfs_path=bucketfs_path,
language_alias=language_alias)
deployer.run(container_file=Path(container_file_path), alter_system=True, allow_override=True)

return func
10 changes: 10 additions & 0 deletions pytest-slc/exasol/pytest_slc/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ATTENTION:
# This file is generated by exasol/toolbox/pre_commit_hooks/package_version.py when using:
# * either "poetry run nox -s fix"
# * or "poetry run version-check <path/version.py> --fix"
# Do not edit this file manually!
# If you need to change the version, do so in the project.toml, e.g. by using `poetry version X.Y.Z`.
MAJOR = 0
MINOR = 1
PATCH = 0
VERSION = f"{MAJOR}.{MINOR}.{PATCH}"
39 changes: 39 additions & 0 deletions pytest-slc/noxconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Configuration for nox based task runner"""
from __future__ import annotations

from dataclasses import dataclass
from pathlib import Path
from typing import (
Any,
Iterable,
MutableMapping,
)

from nox import Session


@dataclass(frozen=True)
class Config:
"""Project specific configuration used by nox infrastructure"""

root: Path = Path(__file__).parent
doc: Path = Path(__file__).parent / "doc"
version_file: Path = Path(__file__).parent / "exasol" / "pytest_slc" / "version.py"
path_filters: Iterable[str] = ("dist", ".eggs", "venv", "metrics-schema")

@staticmethod
def pre_integration_tests_hook(
_session: Session, _config: Config, _context: MutableMapping[str, Any]
) -> bool:
"""Implement if project specific behaviour is required"""
return True

@staticmethod
def post_integration_tests_hook(
_session: Session, _config: Config, _context: MutableMapping[str, Any]
) -> bool:
"""Implement if project specific behaviour is required"""
return True


PROJECT_CONFIG = Config()
11 changes: 11 additions & 0 deletions pytest-slc/noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""defines nox tasks/targets for this project"""
import sys

import nox

print(sys.path)
# imports all nox task provided by the toolbox
from exasol.toolbox.nox.tasks import * # pylint: disable=wildcard-import disable=unused-wildcard-import

# default actions to be run if nothing is explicitly specified with the -s option
nox.options.sessions = ["fix"]
Loading

0 comments on commit 418c713

Please sign in to comment.