File tree 3 files changed +36
-2
lines changed
packit_service/service/api
3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -56,12 +56,13 @@ def get_project_info_from_build(
56
56
57
57
58
58
def get_sync_release_target_info (sync_release_model : SyncReleaseTargetModel ):
59
+ pr_model = sync_release_model .pull_request
59
60
job_result_dict = {
60
61
"status" : sync_release_model .status ,
61
62
"branch" : sync_release_model .branch ,
62
63
"downstream_pr_url" : sync_release_model .downstream_pr_url ,
63
- "downstream_pr_id" : sync_release_model . pull_request . pr_id ,
64
- "downstream_pr_project" : sync_release_model . pull_request . project .project_url ,
64
+ "downstream_pr_id" : pr_model . pr_id if pr_model else None ,
65
+ "downstream_pr_project" : pr_model . project .project_url if pr_model else None ,
65
66
"submitted_time" : optional_timestamp (sync_release_model .submitted_time ),
66
67
"start_time" : optional_timestamp (sync_release_model .start_time ),
67
68
"finished_time" : optional_timestamp (sync_release_model .finished_time ),
Original file line number Diff line number Diff line change @@ -359,6 +359,24 @@ def pull_from_upstream_target_model(release_project_event_model):
359
359
yield target_model
360
360
361
361
362
+ @pytest .fixture ()
363
+ def pull_from_upstream_target_model_without_pr_model (release_project_event_model ):
364
+ pull_from_upstream_model , _ = SyncReleaseModel .create_with_new_run (
365
+ status = SyncReleaseStatus .running ,
366
+ project_event_model = release_project_event_model ,
367
+ job_type = SyncReleaseJobType .pull_from_upstream ,
368
+ )
369
+
370
+ target_model = SyncReleaseTargetModel .create (
371
+ status = SyncReleaseTargetStatus .submitted , branch = SampleValues .branch
372
+ )
373
+ target_model .set_finished_time (finished_time = datetime .datetime .utcnow ())
374
+ target_model .set_logs (logs = "random logs" )
375
+
376
+ pull_from_upstream_model .sync_release_targets .append (target_model )
377
+ yield target_model
378
+
379
+
362
380
@pytest .fixture ()
363
381
def propose_downstream_model_issue (an_issue_project_event_model ):
364
382
propose_downstream_model , _ = SyncReleaseModel .create_with_new_run (
Original file line number Diff line number Diff line change @@ -672,6 +672,21 @@ def test_detailed_propose_info_issue(
672
672
assert response_dict ["issue_id" ] == SampleValues .issue_id
673
673
674
674
675
+ def test_detailed_pull_from_upstream_without_pr_model (
676
+ client , clean_before_and_after , pull_from_upstream_target_model_without_pr_model
677
+ ):
678
+ response = client .get (
679
+ url_for (
680
+ "api.pull-from-upstream_pull_result" ,
681
+ id = pull_from_upstream_target_model_without_pr_model .id ,
682
+ )
683
+ )
684
+ response_dict = response .json
685
+
686
+ assert response_dict ["downstream_pr_project" ] is None
687
+ assert response_dict ["downstream_pr_id" ] is None
688
+
689
+
675
690
@pytest .mark .parametrize (
676
691
"key_to_check" ,
677
692
[
You can’t perform that action at this time.
0 commit comments