Skip to content
Snippets Groups Projects
Commit e010603f authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

:sparkles: add unittests and :rocket: run them in CI

parent ae2cef21
No related branches found
No related tags found
1 merge request!92unittest
.hg
tests
\ No newline at end of file
......@@ -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:
......
......@@ -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] && \
......
......@@ -3,6 +3,8 @@
.. todolist::
.. todo:: Merge pytests junit reports into one.
.. include:: autotodo
......@@ -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
"""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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment