-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from ForgeFlow/add-checklog-odoo
[ADD] oca_checklog_odoo: configurable failure on WARNING log messages
- Loading branch information
Showing
10 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,8 @@ RUN apt-get update -qq \ | |
|
||
# We use manifestoo to check licenses, development status and list addons and dependencies | ||
RUN pipx install --pip-args="--no-cache-dir" "manifestoo>=0.3.1" | ||
# Used in oca_checklog_odoo to check odoo logs for errors and warnings | ||
RUN pipx install --pip-args="--no-cache-dir" checklog-odoo | ||
|
||
# Install pyproject-dependencies helper scripts. | ||
ARG build_deps="setuptools-odoo wheel whool" | ||
|
@@ -155,3 +157,4 @@ ENV INCLUDE= | |
ENV EXCLUDE= | ||
ENV OCA_GIT_USER_NAME=oca-ci | ||
ENV [email protected] | ||
ENV OCA_ENABLE_CHECKLOG_ODOO= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ Environment variables: | |
- `EXCLUDE=` | ||
- `OCA_GIT_USER_NAME=oca-ci`: git user name to commit `.pot` files | ||
- `[email protected]`: git user email to commit | ||
- `OCA_ENABLE_CHECKLOG_ODOO=`: enable odoo log error checking | ||
`.pot` files | ||
|
||
Available commands: | ||
|
@@ -54,6 +55,7 @@ Available commands: | |
- `oca_git_push_if_remote_did_not_change`: push local commits unless the remote | ||
tracked branch has evolved. | ||
- `oca_export_and_push_pot` combines the two previous commands. | ||
- `oca_checklog_odoo` checks odoo logs for errors (including warnings) | ||
|
||
## Build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Check if odoo logs contain errors. Assumes logs will come from stdin | ||
# | ||
|
||
if [ -n "${OCA_ENABLE_CHECKLOG_ODOO}" ]; then | ||
checklog-odoo | ||
else | ||
cat | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "addon that generates warnings", | ||
"version": "1.0.0", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import logging | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
class Test(TransactionCase): | ||
def test_log_warning(self): | ||
_logger.warning("This is a warning") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
import subprocess | ||
from .common import install_test_addons, dropdb, did_run_test_module | ||
|
||
|
||
def test_checklog_enabled(): | ||
"""Test addon_warning with checklog enabled.""" | ||
with install_test_addons(["addon_warning"]) as addons_dir: | ||
dropdb() | ||
subprocess.check_call(["oca_init_test_database"], cwd=addons_dir) | ||
os.environ["OCA_ENABLE_CHECKLOG_ODOO"] = "1" | ||
result = subprocess.run( | ||
["oca_run_tests"], cwd=addons_dir, text=True, capture_output=True | ||
) | ||
os.environ["OCA_ENABLE_CHECKLOG_ODOO"] = "" | ||
assert result.returncode == 1 and "Error: Errors detected in log." in result.stderr | ||
|
||
def test_checklog_disabled(): | ||
"""Test addon_warning with checklog disabled.""" | ||
with install_test_addons(["addon_warning"]) as addons_dir: | ||
dropdb() | ||
subprocess.check_call(["oca_init_test_database"], cwd=addons_dir) | ||
result = subprocess.check_output( | ||
["oca_run_tests"], cwd=addons_dir, text=True | ||
) | ||
assert did_run_test_module(result, "addon_warning.tests.test_warning") |