Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion odoo_repository/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pathlib
import re
import shutil
import tempfile
from unittest.mock import patch

Expand All @@ -24,7 +25,7 @@ def setUpClass(cls):
"odoo_repository_storage_path", cls.repositories_path
)
# org and repository
cls.repo_name = pathlib.Path(cls.repo_upstream_path).parts[-1]
cls.repo_name = cls.repo_upstream_path.parts[-1]
cls.org = cls.env["odoo.repository.org"].create({"name": cls.fork_org})
cls.odoo_repository = cls.env["odoo.repository"].create(
{
Expand Down Expand Up @@ -149,3 +150,14 @@ def _create_odoo_module_branch(cls, module, branch, **values):
}
vals.update(values)
return cls.env["odoo.module.branch"].create(vals)

@classmethod
def tearDownClass(cls):
super().tearDownClass()
shutil.rmtree(cls.repositories_path)

def tearDown(self):
super().tearDown()
repositories_path = pathlib.Path(self.repositories_path)
for sub_path in repositories_path.iterdir():
shutil.rmtree(sub_path)
18 changes: 1 addition & 17 deletions odoo_repository/tests/odoo_repo_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ def setUpClass(cls):
cls.repo_upstream_path = cls._get_upstream_repository_path()
cls.addon_path = Path(cls.repo_upstream_path) / cls.addon
cls.manifest_path = cls.addon_path / "__manifest__.py"
# By cloning the first repository this will set an 'origin' remote
cls.repo_path = cls._clone_tmp_git_repository(cls.repo_upstream_path)
cls._add_fork_remote(cls.repo_path)

@classmethod
def _apply_git_config(cls):
Expand Down Expand Up @@ -101,12 +98,6 @@ def _create_tmp_git_repository(cls) -> Path:
git.Repo.init(repo_path)
return Path(repo_path)

@classmethod
def _clone_tmp_git_repository(cls, upstream_path: Path) -> Path:
repo_path = tempfile.mkdtemp()
git.Repo.clone_from(upstream_path, repo_path)
return Path(repo_path)

@classmethod
def _fill_git_repository(cls, repo_path: Path, addon_path: Path):
"""Create branches with some content in the Git repository."""
Expand Down Expand Up @@ -163,15 +154,8 @@ def _create_module(cls, module_path: Path):
with open(manifest_path, "w") as manifest:
manifest.writelines(manifest_lines)

@classmethod
def _add_fork_remote(cls, repo_path: Path):
repo = git.Repo(repo_path)
# We do not really care about the remote URL here, re-use origin one
repo.create_remote(cls.fork_org, repo.remotes.origin.url)

@classmethod
def tearDownClass(cls):
super().tearDownClass()
# Clean up the Git repository
# Clean up upstream Git repository
shutil.rmtree(cls.repo_upstream_path)
shutil.rmtree(cls.repo_path)