diff --git a/.gitignore b/.gitignore index 5e89e7b..709622c 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ nosetests.xml .testrepository .venv node_modules +.stestr # Translations *.mo diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e525c2..92bfa66 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,6 @@ repos: # python - id: debug-statements - id: check-docstring-first - - id: name-tests-test - id: requirements-txt-fixer diff --git a/.zuul.yaml b/.zuul.yaml index 5598119..b409d2f 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -4,13 +4,10 @@ - check-requirements - publish-openstack-docs-pti - release-notes-jobs-python3 + - openstack-python3-jobs check: jobs: - - openstack-tox-pep8: - required-projects: - - openstack/horizon + - openstack-tox-pep8 gate: jobs: - - openstack-tox-pep8: - required-projects: - - openstack/horizon + - openstack-tox-pep8 diff --git a/pyproject.toml b/pyproject.toml index 6d83acc..ee00e85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,3 +33,8 @@ Documentation = "https://docs.openstack.org/grian-ui/latest/" Repository = "https://opendev.org/openstack/grian-ui" Issues = "https://bugs.launchpad.net/grian-ui" Changelog = "https://docs.openstack.org/releasenotes/grian-ui/" + + +[tool.stestr] +test_path = "./tests/grian_ui_tests/unit" +top_dir = "./" diff --git a/src/grian_ui/main.py b/src/grian_ui/main.py index 4360fa6..c00233d 100644 --- a/src/grian_ui/main.py +++ b/src/grian_ui/main.py @@ -2,5 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 -def main(): - print("hi") +def message() -> str: + return "hi" diff --git a/tests/grian_ui_tests/__init__.py b/tests/grian_ui_tests/__init__.py new file mode 100644 index 0000000..1fc32ae --- /dev/null +++ b/tests/grian_ui_tests/__init__.py @@ -0,0 +1,2 @@ +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/tests/grian_ui_tests/grian_fixtures/__init__.py b/tests/grian_ui_tests/grian_fixtures/__init__.py new file mode 100644 index 0000000..1fc32ae --- /dev/null +++ b/tests/grian_ui_tests/grian_fixtures/__init__.py @@ -0,0 +1,2 @@ +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/tests/grian_ui_tests/unit/__init__.py b/tests/grian_ui_tests/unit/__init__.py new file mode 100644 index 0000000..1fc32ae --- /dev/null +++ b/tests/grian_ui_tests/unit/__init__.py @@ -0,0 +1,2 @@ +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/tests/grian_ui_tests/unit/base.py b/tests/grian_ui_tests/unit/base.py new file mode 100644 index 0000000..b6ca4d3 --- /dev/null +++ b/tests/grian_ui_tests/unit/base.py @@ -0,0 +1,8 @@ +# +# SPDX-License-Identifier: Apache-2.0 + +from django import test + + +class TestCase(test.SimpleTestCase): + pass diff --git a/tests/grian_ui_tests/unit/settings.py b/tests/grian_ui_tests/unit/settings.py new file mode 100644 index 0000000..1fc32ae --- /dev/null +++ b/tests/grian_ui_tests/unit/settings.py @@ -0,0 +1,2 @@ +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/tests/grian_ui_tests/unit/test_main.py b/tests/grian_ui_tests/unit/test_main.py new file mode 100644 index 0000000..d9174b1 --- /dev/null +++ b/tests/grian_ui_tests/unit/test_main.py @@ -0,0 +1,10 @@ +# +# SPDX-License-Identifier: Apache-2.0 + +from grian_ui import main +from grian_ui_tests.unit import base + + +class MainTests(base.TestCase): + def test_message(self): + self.assertEqual("hi", main.message()) diff --git a/tox.ini b/tox.ini index 2cccd77..30aad39 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 3.18.0 -envlist = pep8,unit +envlist = pep8,unit,docs,releasenotes [testenv] @@ -20,7 +20,12 @@ setenv = OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=160 PYTHONDONTWRITEBYTECODE=1 + # this is required to make the tests available + # as they are not part of the package. + PYTHONPATH = {toxinidir}/tests:{envdir} + DJANGO_SETTINGS_MODULE=grian_ui_tests.unit.settings deps = + -r requirements.txt -r{toxinidir}/test-requirements.txt passenv = # LOCALE_ARCHIVE is needed when not using python from the system package