Skip to content

Commit 048dd1f

Browse files
committedSep 2, 2024
refactor: add hg_export_tip function
1 parent 5b7ca17 commit 048dd1f

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed
 

‎tests/test_integration.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
from git import Repo
88
from mozlog import get_proxy_logger
9+
from utils import hg_export_tip
910

1011
from git_hg_sync.__main__ import get_connection, get_queue, start_app
1112
from git_hg_sync.config import Config
@@ -77,12 +78,5 @@ def test_full_app(
7778
# execute app
7879
start_app(config, get_proxy_logger("test"), one_shot=True)
7980

80-
# tests
81-
process = subprocess.run(
82-
["hg", "export", "tip"],
83-
cwd=hg_remote_repo_path,
84-
check=True,
85-
capture_output=True,
86-
text=True,
87-
)
88-
assert "FOO CONTENT" in process.stdout
81+
# test
82+
assert "FOO CONTENT" in hg_export_tip(hg_remote_repo_path)

‎tests/test_repo_synchronizer.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import pytest
55
from git import Repo
6+
from utils import hg_export_tip
67

78
from git_hg_sync.__main__ import get_connection, get_queue
89
from git_hg_sync.config import TrackedRepository
@@ -41,14 +42,8 @@ def test_sync_process_(
4142
syncrepos = RepoSynchronizer(git_local_repo_path, str(git_remote_repo_path))
4243
syncrepos.sync_branches(str(hg_remote_repo_path), [(git_commit_sha, "foo")])
4344

44-
process = subprocess.run(
45-
["hg", "export", "tip"],
46-
cwd=hg_remote_repo_path,
47-
check=True,
48-
capture_output=True,
49-
text=True,
50-
)
51-
assert "FOO CONTENT" in process.stdout
45+
# test
46+
assert "FOO CONTENT" in hg_export_tip(hg_remote_repo_path)
5247

5348

5449
def test_get_connection_and_queue(pulse_config):

‎tests/utils.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import subprocess
2+
3+
4+
def hg_export_tip(repo_path: str):
5+
process = subprocess.run(
6+
["hg", "export", "tip"],
7+
cwd=repo_path,
8+
check=True,
9+
capture_output=True,
10+
text=True,
11+
)
12+
return process.stdout

0 commit comments

Comments
 (0)
Failed to load comments.