diff --git a/.dockerignore b/.dockerignore index ae2cef217ff92686cc6684d03fa4b47ebeb3b179_LmRvY2tlcmlnbm9yZQ==..e010603fec5a60f95061a99adbd29944dcf83698_LmRvY2tlcmlnbm9yZQ== 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,1 +1,2 @@ .hg +tests \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae2cef217ff92686cc6684d03fa4b47ebeb3b179_LmdpdGxhYi1jaS55bWw=..e010603fec5a60f95061a99adbd29944dcf83698_LmdpdGxhYi1jaS55bWw= 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,6 +21,39 @@ TAG_COMMIT_SHA: "yes" TAG_BRANCH: "no" +pylint: + needs: + - job: build-docker-image + image: $TEMP_IMAGE + variables: + PYLINT_FILES: odoo_scripts doc tests + +unittest: + needs: [] + stage: test + image: fkrull/multi-python + script: + - tox --workdir=.cache/tox --parallel all -e py36,py37,py38,py39,coverage-report,coverage-xml + artifacts: + when: always + reports: + cobertura: coverage.xml + junit: report.py36.xml + coverage: "/TOTAL.+ ([0-9]{1,3}%)/" + cache: + paths: + - .cache + variables: + PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip + +unittest-py310: + extends: unittest + image: python:3.10-alpine + script: + - apk add git + - python3 -m pip install tox + - tox --workdir=.cache/tox -e py310,coverage-report,coverage-xml + import_jsonrpc_odoo11_test: stage: test needs: [] @@ -121,10 +154,12 @@ extends: build-docker-image stage: deploy needs: - - job: docker_build_copy_test - - job: import_jsonrpc_odoo11_test - - job: import_jsonrpc_odoo13_test - - job: import_base_import_odoo11_test + - job: docker_build_copy_test + - job: import_jsonrpc_odoo11_test + - job: import_jsonrpc_odoo13_test + - job: import_base_import_odoo11_test + - job: unittest + - job: unittest-py310 variables: TAG_LATEST: branch/default script: diff --git a/Dockerfile b/Dockerfile index ae2cef217ff92686cc6684d03fa4b47ebeb3b179_RG9ja2VyZmlsZQ==..e010603fec5a60f95061a99adbd29944dcf83698_RG9ja2VyZmlsZQ== 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,6 @@ ADD . /usr/src/odoo_scripts RUN set -x ;\ apk add --no-cache --update zsh rsync postgresql-libs && \ - # mercurial && \ apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev git && \ python3 -m pip install -r /usr/src/odoo_scripts/requirements && \ python3 -m pip install /usr/src/odoo_scripts[import_sql,conf2reST,source_control] && \ diff --git a/TODO.rst b/TODO.rst index ae2cef217ff92686cc6684d03fa4b47ebeb3b179_VE9ETy5yc3Q=..e010603fec5a60f95061a99adbd29944dcf83698_VE9ETy5yc3Q= 100644 --- a/TODO.rst +++ b/TODO.rst @@ -3,6 +3,8 @@ .. todolist:: +.. todo:: Merge pytests junit reports into one. + .. include:: autotodo diff --git a/pyproject.toml b/pyproject.toml index ae2cef217ff92686cc6684d03fa4b47ebeb3b179_cHlwcm9qZWN0LnRvbWw=..e010603fec5a60f95061a99adbd29944dcf83698_cHlwcm9qZWN0LnRvbWw= 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,3 +23,42 @@ [tool.isort] profile = "black" +[tool.coverage.run] +branch = true +source = ["odoo_scripts"] + +[tool.coverage.report] +show_missing = true + +[tool.tox] +legacy_tox_ini = """ +[tox] +minversion = 3.15 +envlist = py36,py37,py38,py39,py310,coverage-report +skip_missing_interpreters = true + +[testenv:py{36,37,38,39,310}] +setenv = + COVERAGE_FILE = .coverage.{envname} +deps = + coverage[toml] + pytest + py310: git+https://github.com/xcgd/odoorpc@fix-oca-issue-66#egg=odoorpc +commands = coverage run -m pytest --junitxml=report.{envname}.xml {posargs} + +[testenv:coverage-report] +skip_install = true +deps = coverage[toml] +depends = py36,py37,py38,py39,py310 +commands = + coverage combine + coverage report +parallel_show_output = true + +[testenv:coverage-xml] +skip_install = true +deps = coverage[toml] +depends = coverage-report +commands = + coverage xml +""" \ No newline at end of file diff --git a/tests/config-empty/setup.cfg b/tests/config-empty/setup.cfg new file mode 100644 diff --git a/tests/config-no-file/empty b/tests/config-no-file/empty new file mode 100644 diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000000000000000000000000000000000000..e010603fec5a60f95061a99adbd29944dcf83698_dGVzdHMvdGVzdF9jb25maWcucHk= --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,22 @@ +"""Tests of the config module""" +import unittest + +from odoo_scripts.config import Configuration + + +class ConfigTestCase(unittest.TestCase): + """Tests of the config module""" + + def test_no_conf(self): + """Test when there is no configuration file""" + configuration = Configuration("config-no-file/") + self.assertEqual(configuration.modules, []) + + def test_empty_conf(self): + """Test when there is no configuration file""" + configuration = Configuration("config-empty/") + self.assertEqual(configuration.modules, []) + + +if __name__ == "__main__": + unittest.main()