Skip to content

Commit b9d57aa

Browse files
committed
[FIX] odoo_repository: fix tests cleanup and remove unused code
Following up 6000479
1 parent 0e30c87 commit b9d57aa

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

odoo_repository/tests/common.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import pathlib
66
import re
7+
import shutil
78
import tempfile
89
from unittest.mock import patch
910

@@ -24,7 +25,7 @@ def setUpClass(cls):
2425
"odoo_repository_storage_path", cls.repositories_path
2526
)
2627
# org and repository
27-
cls.repo_name = pathlib.Path(cls.repo_upstream_path).parts[-1]
28+
cls.repo_name = cls.repo_upstream_path.parts[-1]
2829
cls.org = cls.env["odoo.repository.org"].create({"name": cls.fork_org})
2930
cls.odoo_repository = cls.env["odoo.repository"].create(
3031
{
@@ -149,3 +150,14 @@ def _create_odoo_module_branch(cls, module, branch, **values):
149150
}
150151
vals.update(values)
151152
return cls.env["odoo.module.branch"].create(vals)
153+
154+
@classmethod
155+
def tearDownClass(cls):
156+
super().tearDownClass()
157+
shutil.rmtree(cls.repositories_path)
158+
159+
def tearDown(self):
160+
super().tearDown()
161+
repositories_path = pathlib.Path(self.repositories_path)
162+
for sub_path in repositories_path.iterdir():
163+
shutil.rmtree(sub_path)

odoo_repository/tests/odoo_repo_mixin.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ def setUpClass(cls):
3535
cls.repo_upstream_path = cls._get_upstream_repository_path()
3636
cls.addon_path = Path(cls.repo_upstream_path) / cls.addon
3737
cls.manifest_path = cls.addon_path / "__manifest__.py"
38-
# By cloning the first repository this will set an 'origin' remote
39-
cls.repo_path = cls._clone_tmp_git_repository(cls.repo_upstream_path)
40-
cls._add_fork_remote(cls.repo_path)
4138

4239
@classmethod
4340
def _apply_git_config(cls):
@@ -101,12 +98,6 @@ def _create_tmp_git_repository(cls) -> Path:
10198
git.Repo.init(repo_path)
10299
return Path(repo_path)
103100

104-
@classmethod
105-
def _clone_tmp_git_repository(cls, upstream_path: Path) -> Path:
106-
repo_path = tempfile.mkdtemp()
107-
git.Repo.clone_from(upstream_path, repo_path)
108-
return Path(repo_path)
109-
110101
@classmethod
111102
def _fill_git_repository(cls, repo_path: Path, addon_path: Path):
112103
"""Create branches with some content in the Git repository."""
@@ -163,15 +154,8 @@ def _create_module(cls, module_path: Path):
163154
with open(manifest_path, "w") as manifest:
164155
manifest.writelines(manifest_lines)
165156

166-
@classmethod
167-
def _add_fork_remote(cls, repo_path: Path):
168-
repo = git.Repo(repo_path)
169-
# We do not really care about the remote URL here, re-use origin one
170-
repo.create_remote(cls.fork_org, repo.remotes.origin.url)
171-
172157
@classmethod
173158
def tearDownClass(cls):
174159
super().tearDownClass()
175-
# Clean up the Git repository
160+
# Clean up upstream Git repository
176161
shutil.rmtree(cls.repo_upstream_path)
177-
shutil.rmtree(cls.repo_path)

0 commit comments

Comments
 (0)