Skip to content

Commit

Permalink
Merge pull request #1673 from mathbunnyru/asalikhov/modules
Browse files Browse the repository at this point in the history
Make tests a module and make imports absolute
  • Loading branch information
mathbunnyru committed May 1, 2022
2 parents 05c4ef4 + c6ae418 commit 81a93d2
Show file tree
Hide file tree
Showing 28 changed files with 61 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ run-sudo-shell/%: ## run a bash in interactive mode as root in a stack

test/%: ## run tests against a stack
@echo "::group::test/$(OWNER)/$(notdir $@)"
tests/run_tests.py --short-image-name "$(notdir $@)" --owner "$(OWNER)"
python3 -m tests.run_tests --short-image-name "$(notdir $@)" --owner "$(OWNER)"
@echo "::endgroup::"
test-all: $(foreach I, $(ALL_IMAGES), test/$(I)) ## test all stacks
11 changes: 9 additions & 2 deletions tagging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ In this section we will briefly describe source code in this folder and give exa
`DockerRunner` is a helper class to easily run a docker container and execute commands inside this container:

```python
from .docker_runner import DockerRunner
from tagging.docker_runner import DockerRunner

with DockerRunner("ubuntu:bionic") as container:
DockerRunner.run_simple_command(container, cmd="env", print_result=True)
Expand All @@ -38,7 +38,7 @@ with DockerRunner("ubuntu:bionic") as container:
`GitHelper` methods are run in the current `git` repo and give the information about last commit hash and commit message:

```python
from .git_helper import GitHelper
from tagging.git_helper import GitHelper

print("Git hash:", GitHelper.commit_hash())
print("Git message:", GitHelper.commit_message())
Expand Down Expand Up @@ -66,6 +66,10 @@ So, `tag_value(container)` method gets a docker container as an input and return
`SHATagger` example:

```python
from tagging.git_helper import GitHelper
from tagging.taggers import TaggerInterface


class SHATagger(TaggerInterface):
@staticmethod
def tag_value(container):
Expand Down Expand Up @@ -96,6 +100,9 @@ class ManifestInterface:
`AptPackagesManifest` example:

```python
from tagging.manifests import ManifestInterface, quoted_output


class AptPackagesManifest(ManifestInterface):
@staticmethod
def markdown_piece(container) -> str:
Expand Down
8 changes: 4 additions & 4 deletions tagging/create_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from docker.models.containers import Container

from .docker_runner import DockerRunner
from .get_taggers_and_manifests import get_taggers_and_manifests
from .git_helper import GitHelper
from .manifests import ManifestHeader, ManifestInterface
from tagging.docker_runner import DockerRunner
from tagging.get_taggers_and_manifests import get_taggers_and_manifests
from tagging.git_helper import GitHelper
from tagging.manifests import ManifestHeader, ManifestInterface

LOGGER = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions tagging/get_taggers_and_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Distributed under the terms of the Modified BSD License.
from typing import Optional

from .images_hierarchy import ALL_IMAGES
from .manifests import ManifestInterface
from .taggers import TaggerInterface
from tagging.images_hierarchy import ALL_IMAGES
from tagging.manifests import ManifestInterface
from tagging.taggers import TaggerInterface


def get_taggers_and_manifests(
Expand Down
4 changes: 2 additions & 2 deletions tagging/images_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from dataclasses import dataclass, field
from typing import Optional

from .manifests import (
from tagging.manifests import (
AptPackagesManifest,
CondaEnvironmentManifest,
JuliaPackagesManifest,
ManifestInterface,
RPackagesManifest,
SparkInfoManifest,
)
from .taggers import (
from tagging.taggers import (
DateTagger,
HadoopVersionTagger,
JavaVersionTagger,
Expand Down
4 changes: 2 additions & 2 deletions tagging/manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import plumbum
from docker.models.containers import Container

from .docker_runner import DockerRunner
from .git_helper import GitHelper
from tagging.docker_runner import DockerRunner
from tagging.git_helper import GitHelper

docker = plumbum.local["docker"]

Expand Down
6 changes: 3 additions & 3 deletions tagging/tag_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import plumbum

from .docker_runner import DockerRunner
from .get_taggers_and_manifests import get_taggers_and_manifests
from .github_set_env import github_set_env
from tagging.docker_runner import DockerRunner
from tagging.get_taggers_and_manifests import get_taggers_and_manifests
from tagging.github_set_env import github_set_env

docker = plumbum.local["docker"]

Expand Down
4 changes: 2 additions & 2 deletions tagging/taggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from docker.models.containers import Container

from .docker_runner import DockerRunner
from .git_helper import GitHelper
from tagging.docker_runner import DockerRunner
from tagging.git_helper import GitHelper


def _get_program_version(container: Container, program: str) -> str:
Expand Down
Empty file added tests/__init__.py
Empty file.
3 changes: 2 additions & 1 deletion tests/all-spark-notebook/test_spark_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from pathlib import Path

import pytest # type: ignore
from conftest import TrackedContainer

from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)
THIS_DIR = Path(__file__).parent.resolve()
Expand Down
3 changes: 2 additions & 1 deletion tests/base-notebook/test_container_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import pytest # type: ignore
import requests
from conftest import TrackedContainer, find_free_port

from tests.conftest import TrackedContainer, find_free_port

LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion tests/base-notebook/test_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@


import requests
from conftest import TrackedContainer, find_free_port

from tests.conftest import TrackedContainer, find_free_port


def test_secured_server(
Expand Down
5 changes: 3 additions & 2 deletions tests/base-notebook/test_outdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import logging

import pytest # type: ignore
from conftest import TrackedContainer
from package_helper import CondaPackageHelper

from tests.conftest import TrackedContainer
from tests.package_helper import CondaPackageHelper

LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion tests/base-notebook/test_package_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import logging

import pytest # type: ignore
from conftest import TrackedContainer

from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions tests/base-notebook/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
from typing import Callable, Iterable

import pytest # type: ignore
from conftest import TrackedContainer
from package_helper import CondaPackageHelper

from tests.conftest import TrackedContainer
from tests.package_helper import CondaPackageHelper

LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/base-notebook/test_pandoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import logging

from conftest import TrackedContainer
from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion tests/base-notebook/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# Distributed under the terms of the Modified BSD License.
import logging

from conftest import TrackedContainer
from packaging import version # type: ignore

from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)


Expand Down
3 changes: 2 additions & 1 deletion tests/base-notebook/test_start_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import pytest # type: ignore
import requests
from conftest import TrackedContainer, find_free_port

from tests.conftest import TrackedContainer, find_free_port

LOGGER = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions tests/base-notebook/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import logging

from conftest import TrackedContainer
from images_hierarchy import get_test_dirs
from tests.conftest import TrackedContainer
from tests.images_hierarchy import get_test_dirs

LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/datascience-notebook/test_julia.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Distributed under the terms of the Modified BSD License.
import logging

from conftest import TrackedContainer
from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/minimal-notebook/test_inkscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import logging

from conftest import TrackedContainer
from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion tests/minimal-notebook/test_nbconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from pathlib import Path

import pytest # type: ignore
from conftest import TrackedContainer

from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)
THIS_DIR = Path(__file__).parent.resolve()
Expand Down
3 changes: 2 additions & 1 deletion tests/package_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
from itertools import chain
from typing import Any, Optional

from conftest import TrackedContainer
from docker.models.containers import Container
from tabulate import tabulate

from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion tests/pyspark-notebook/test_spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Distributed under the terms of the Modified BSD License.
import logging

from conftest import TrackedContainer
from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import logging

import plumbum
from images_hierarchy import get_test_dirs

from tests.images_hierarchy import get_test_dirs

pytest = plumbum.local["pytest"]

Expand Down
2 changes: 1 addition & 1 deletion tests/scipy-notebook/test_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pathlib import Path

from conftest import TrackedContainer
from tests.conftest import TrackedContainer

THIS_DIR = Path(__file__).parent.resolve()

Expand Down
3 changes: 2 additions & 1 deletion tests/scipy-notebook/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging

import pytest # type: ignore
from conftest import TrackedContainer

from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion tests/scipy-notebook/test_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from pathlib import Path

import pytest # type: ignore
from conftest import TrackedContainer

from tests.conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)
THIS_DIR = Path(__file__).parent.resolve()
Expand Down

0 comments on commit 81a93d2

Please sign in to comment.