11import sys
2+ from collections .abc import Callable
3+ from pathlib import Path
24
35import mozlog
46import mozlog .formatters
57import mozlog .handlers
68import pytest
79
8- from git_hg_sync .config import PulseConfig
10+ from git_hg_sync .config import ClonesConfig , Config , PulseConfig , TrackedRepository
11+ from git_hg_sync .mapping import BranchMapping
912
1013
1114@pytest .fixture (autouse = True , scope = "session" )
@@ -27,5 +30,42 @@ def pulse_config() -> PulseConfig:
2730 routing_key = "#" ,
2831 queue = "queue/guest/test" ,
2932 password = "guest" ,
33+ heartbeat = 30 ,
3034 ssl = False ,
3135 )
36+
37+ @pytest .fixture
38+ def test_config (pulse_config : PulseConfig ) -> Config :
39+ return Config (
40+ pulse = pulse_config ,
41+ clones = ClonesConfig (directory = Path ("clones" )),
42+ tracked_repositories = [
43+ TrackedRepository (name = "mozilla-central" , url = "https://github.com/mozilla-firefox/firefox.git" ),
44+ ],
45+ branch_mappings = [BranchMapping (
46+ branch_pattern = '.*' ,
47+ source_url = "https://github.com/mozilla-firefox/firefox.git" ,
48+ destination_url = 'destination_url' ,
49+ destination_branch = 'destination_branch' ,
50+ )],
51+ )
52+
53+ @pytest .fixture
54+ def get_payload () -> Callable :
55+
56+ def get_payload (** kwargs : dict ) -> dict :
57+ """Return a default payload, with override via kwargs."""
58+ payload = {
59+ "type" : "push" ,
60+ "repo_url" : "repo.git" ,
61+ "branches" : { "main" : 40 * "0" },
62+ "tags" : {},
63+ "time" : 0 ,
64+ "push_id" : 0 ,
65+ "user" : "user" ,
66+ "push_json_url" : "push_json_url" ,
67+ }
68+ payload .update (kwargs )
69+ return payload
70+
71+ return get_payload
0 commit comments