Skip to content

Commit

Permalink
Merge pull request #75 from yvaucher/pytest-mock-odoo
Browse files Browse the repository at this point in the history
Mock Odoo module for unit tests
  • Loading branch information
yvaucher authored Oct 5, 2024
2 parents 095ca9f + edbdd04 commit c68bc3d
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit = tests/*
setup.py
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jobs:
pip install tox codecov tox-gh-actions wheel
- name: Generate Report
run: |
pip install coverage
pip install .[test]
coverage run -m unittest
tox run
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
21 changes: 17 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
*.egg-info
*.pyc
.cache/
dist/
# Byte-compiled / optimized / DLL
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
build/
dist/
eggs/
.eggs/
*.egg-info/
*.egg

# Unit test / coverage reports
.tox
.coverage
.coverage.*
.cache/
3 changes: 3 additions & 0 deletions tests/mock/odoo/odoo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from mock import MagicMock
registry = MagicMock()
tools = MagicMock()
2 changes: 2 additions & 0 deletions tests/mock/odoo/odoo/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from mock import MagicMock
common = MagicMock()
12 changes: 12 additions & 0 deletions tests/mock/odoo/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from setuptools import find_packages, setup

setup(
name="odoo",
version="0.0.1",
packages=find_packages(),
package_dir={"odoo": "odoo"},
install_requires="mock"
)
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[testenv]
deps = pytest
pytest-cov
coverage
commands =
pip install tests/mock/odoo
pytest --cov=pytest_odoo . --cov-report=xml

0 comments on commit c68bc3d

Please sign in to comment.