Skip to content

Commit

Permalink
test(RHTAPWATCH-643): Adding python tests to CI
Browse files Browse the repository at this point in the history
Signed-off-by: Yftach Herzog <[email protected]>
  • Loading branch information
yftacherzog committed Dec 7, 2023
1 parent 05a63e2 commit 8831254
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 2 deletions.
2 changes: 2 additions & 0 deletions compose_generator/compose_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Top level generic entity for creating a compose"""
from dataclasses import dataclass

from .protocols import (
Expand All @@ -20,6 +21,7 @@ class ComposeGenerator:
:param requestor: an object to request a new composed
:param fetcher: an object to fetch a compose once it's ready
"""

configurations_generator: ComposeConfigurationsGenerator
requestor: ComposeRequester
fetcher: ComposeFetcher
Expand Down
6 changes: 4 additions & 2 deletions compose_generator/odcs_compose_generator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python3

"""Initialize and use a compose generator using ODCS"""

from .compose_generator import ComposeGenerator
from .odcs_configurations_generator import ODCSConfigurationsGenerator
from .odcs_fetcher import ODCSFetcher
from .odcs_requester import ODCSRequester
from .odcs_configurations_generator import ODCSConfigurationsGenerator
from .compose_generator import ComposeGenerator


def main():
Expand Down
2 changes: 2 additions & 0 deletions compose_generator/odcs_configurations_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Configurations generator for ODCS compose"""
from dataclasses import dataclass

from .protocols import ComposeConfigurations, ComposeConfigurationsGenerator
Expand All @@ -18,6 +19,7 @@ class ODCSConfigurationsGenerator(ComposeConfigurationsGenerator):
:param container_data: data loaded from container.yaml
:param content_sets_data: data loaded from content_sets.yaml
"""

container_data: dict
content_sets_data: dict

Expand Down
3 changes: 3 additions & 0 deletions compose_generator/odcs_fetcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Fetch ready ODCS compose"""
from dataclasses import dataclass
from pathlib import Path

Expand All @@ -9,6 +10,7 @@ class ODCSResultReference(ComposeReference):
"""
Reference to a locally-stored compose result
"""

compose_path: Path


Expand All @@ -17,5 +19,6 @@ class ODCSFetcher(ComposeFetcher):
"""
Fetch ODCS compose based on a remote compose-reference and store it locally
"""

def __call__(self, request_reference: ComposeReference) -> ODCSResultReference:
raise NotImplementedError()
3 changes: 3 additions & 0 deletions compose_generator/odcs_requester.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Request a new ODCS compose"""
from dataclasses import dataclass

from .protocols import ComposeConfigurations, ComposeReference, ComposeRequester
Expand All @@ -8,6 +9,7 @@ class ODCSRequestReference(ComposeReference):
"""
Reference to a remotely-stored compose data
"""

compose_url: str


Expand All @@ -17,5 +19,6 @@ class ODCSRequester(ComposeRequester):
Request a new ODCS compose based on compose configurations and return a reference
to the remote compose location.
"""

def __call__(self, configs: ComposeConfigurations) -> ODCSRequestReference:
raise NotImplementedError()
5 changes: 5 additions & 0 deletions compose_generator/protocols.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""compose generator protocols"""
from typing import Protocol

# pylint: disable=too-few-public-methods


class ComposeConfigurations(Protocol):
"""
Expand All @@ -11,6 +14,7 @@ class ComposeConfigurationsGenerator(Protocol):
"""
Generate compose configurations
"""

def __call__(self) -> ComposeConfigurations:
pass

Expand All @@ -25,6 +29,7 @@ class ComposeRequester(Protocol):
"""
Given compose configurations, return a remote compose reference
"""

def __call__(self, configs: ComposeConfigurations) -> ComposeReference:
pass

Expand Down
11 changes: 11 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -ex

main() {
local pkgs=("tests" "compose_generator")
pipenv run isort --profile black "${pkgs[@]}"
pipenv run black "${pkgs[@]}"
}

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
main "$@"
fi
25 changes: 25 additions & 0 deletions tests/test_static_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Static checks"""
from subprocess import run
from typing import Final

PKGS: Final[list[str]] = ["tests", "compose_generator"]


def test_mypy() -> None:
"""Static Type check"""
run(["mypy"] + PKGS, check=True)


def test_isort() -> None:
"""Imports formatting check"""
run(["isort", "--check", "--profile", "black"] + PKGS, check=True)


def test_black() -> None:
"""Formatting check"""
run(["black", "--check"] + PKGS, check=True)


def test_pylint() -> None:
"""Lint check"""
run(["pylint"] + PKGS, check=True)

0 comments on commit 8831254

Please sign in to comment.