-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Test some other downstream tasks on the way. - Fix permission problems detected with those tests. - Fix race condition when running several docker tasks.
- Loading branch information
1 parent
d1234a2
commit 4132ea2
Showing
6 changed files
with
120 additions
and
5 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
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
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
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,82 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
from copier import copy | ||
from plumbum import ProcessExecutionError, local | ||
from plumbum.cmd import docker_compose, invoke | ||
|
||
|
||
def _install_status(module, dbname="devel"): | ||
return docker_compose( | ||
"run", | ||
"--rm", | ||
"-e", | ||
"LOG_LEVEL=WARNING", | ||
"-e", | ||
f"PGDATABASE={dbname}", | ||
"odoo", | ||
"psql", | ||
"-tc", | ||
f"select state from ir_module_module where name='{module}'", | ||
).strip() | ||
|
||
|
||
@pytest.mark.skipif( | ||
os.environ.get("DOCKER_TEST") != "1", reason="Missing DOCKER_TEST=1 env variable" | ||
) | ||
def test_resetdb(tmp_path: Path, cloned_template: Path, supported_odoo_version: float): | ||
"""Test the dropdb task. | ||
On this test flow, other downsream tasks are also tested: | ||
- img-build | ||
- git-aggregate | ||
- stop --purge | ||
""" | ||
with local.cwd(tmp_path): | ||
copy( | ||
src_path=str(cloned_template), | ||
vcs_ref="HEAD", | ||
force=True, | ||
data={"odoo_version": supported_odoo_version}, | ||
) | ||
try: | ||
invoke("img-build") | ||
invoke("git-aggregate") | ||
# No ir_module_module table exists yet | ||
with pytest.raises(ProcessExecutionError): | ||
_install_status("base") | ||
# This should install just "base" addon | ||
stdout = invoke("resetdb") | ||
assert "Creating database cache" in stdout | ||
assert "from template devel" in stdout | ||
assert _install_status("base") == "installed" | ||
assert _install_status("purchase") == "uninstalled" | ||
assert _install_status("sale") == "uninstalled" | ||
# Install "purchase" | ||
stdout = invoke("resetdb", "-m", "purchase") | ||
assert "Creating database cache" in stdout | ||
assert "from template devel" in stdout | ||
assert _install_status("base") == "installed" | ||
assert _install_status("purchase") == "installed" | ||
assert _install_status("sale") == "uninstalled" | ||
# Install "sale" in a separate database | ||
stdout = invoke("resetdb", "-m", "sale", "-d", "sale_only") | ||
assert "Creating database cache" in stdout | ||
assert "from template sale_only" in stdout | ||
assert _install_status("base") == "installed" | ||
assert _install_status("purchase") == "installed" | ||
assert _install_status("sale") == "uninstalled" | ||
assert _install_status("base", "sale_only") == "installed" | ||
assert _install_status("purchase", "sale_only") == "uninstalled" | ||
assert _install_status("sale", "sale_only") == "installed" | ||
# Install "sale" in main database | ||
stdout = invoke("resetdb", "-m", "sale") | ||
assert "Creating database devel from template cache" in stdout | ||
assert "Found matching database template" in stdout | ||
assert _install_status("base") == "installed" | ||
assert _install_status("purchase") == "uninstalled" | ||
assert _install_status("sale") == "installed" | ||
finally: | ||
invoke("stop", "--purge") |