From cafcff26d8a551b30a4cae133435b120fa0b5f2d Mon Sep 17 00:00:00 2001 From: Zaharia Constantin <1303303+soulraven@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:15:42 +0300 Subject: [PATCH] Make some basic test to pass the ci/cd --- tests/__init__.py | 8 ++++++++ tests/test_basic.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_basic.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..ce94cba --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +# A Python "namespace package" http://www.python.org/dev/peps/pep-0382/ +# This always goes inside a namespace package's __init__.py + +from pkgutil import extend_path + +__path__ = extend_path(__path__, __name__) diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..2717ff0 --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +import os +import pytest + +from pathlib import Path + + +def file_contains_text(file: Path, text: str) -> bool: + return open(file, "r").read().find(text) != -1 + + +@pytest.fixture(scope="module") +def script_loc(request): + """Return the directory of the currently running test script + + :param request: + :return: + """ + + return Path(request.fspath).parent.parent + + +def test_cicd(script_loc): + assert file_contains_text( + script_loc.joinpath("Makefile"), "build-and-publish" + ), "From the Makefile is missing the build-and-publish command" + + +def test_tox(script_loc): + """ + + :param script_loc: + :return: + """ + assert file_contains_text( + script_loc.joinpath(".github/workflows/push_to_main.yml"), + "poetry add tox-gh-actions", + ) + assert os.path.isfile(script_loc.joinpath("tox.ini"))