88from mergin .client_push import push_project_finalize , UploadJob
99from mergin .common import ClientError
1010
11+
1112@pytest .mark .parametrize ("status_code" , [502 , 504 ])
1213def test_push_finalize_logs_on_5xx_real_diff (caplog , status_code , tmp_path ):
1314 # --- data ---
@@ -30,17 +31,26 @@ def test_push_finalize_logs_on_5xx_real_diff(caplog, status_code, tmp_path):
3031
3132 # --- fake MP/MC len tam, kde treba ---
3233 class MP :
33- def __init__ (self , log ): self .log = log
34- def update_metadata (self , * a , ** k ): pass
35- def apply_push_changes (self , * a , ** k ): pass
36- def fpath_meta (self , rel ): return str (diff_path ) if rel == diff_path .name else rel
34+ def __init__ (self , log ):
35+ self .log = log
36+
37+ def update_metadata (self , * a , ** k ):
38+ pass
39+
40+ def apply_push_changes (self , * a , ** k ):
41+ pass
42+
43+ def fpath_meta (self , rel ):
44+ return str (diff_path ) if rel == diff_path .name else rel
3745
3846 tx = "tx-1"
3947
4048 class MC :
4149 def post (self , url , * args , ** kwargs ):
4250 if url .endswith (f"/v1/project/push/finish/{ tx } " ):
43- err = ClientError ("Gateway error" ); setattr (err , "http_error" , status_code ); raise err
51+ err = ClientError ("Gateway error" )
52+ setattr (err , "http_error" , status_code )
53+ raise err
4454 if url .endswith (f"/v1/project/push/cancel/{ tx } " ):
4555 return SimpleNamespace (msg = "cancelled" )
4656 return SimpleNamespace (msg = "ok" )
@@ -52,12 +62,14 @@ def post(self, url, *args, **kwargs):
5262 project_path = "u/p" ,
5363 changes = {
5464 "added" : [],
55- "updated" : [{
56- "path" : modified .name ,
57- "size" : file_size ,
58- "diff" : {"path" : diff_path .name , "size" : diff_size },
59- "chunks" : [1 ],
60- }],
65+ "updated" : [
66+ {
67+ "path" : modified .name ,
68+ "size" : file_size ,
69+ "diff" : {"path" : diff_path .name , "size" : diff_size },
70+ "chunks" : [1 ],
71+ }
72+ ],
6173 "removed" : [],
6274 },
6375 transaction_id = tx ,
@@ -84,4 +96,4 @@ def post(self, url, *args, **kwargs):
8496 assert modified .name in text
8597 assert f"size={ file_size } " in text
8698 assert f"diff_size={ diff_size } " in text
87- assert ("changes=" in text ) or ("changes=n/a" in text )
99+ assert ("changes=" in text ) or ("changes=n/a" in text )
0 commit comments