コード例 #1
0
def test_synthesize_loop_with_realistic_change_history_squash_prs(
    synthesize_loop_fixture: SynthesizeLoopFixture, ):
    pusher = synthesize_loop_fixture.change_pusher
    synthesize_loop_fixture.change_pusher = SquashingChangePusher(pusher)
    synthesize_loop_with_realistic_change_history(
        synthesize_loop_fixture, True, "mock-synth-golden-squash-prs.log")
    calls = pusher.mock_calls
    golden_calls = [
        call.check_if_pr_already_exists("test-source1"),
        call.push_changes(
            1,
            "test-source1",
            "[CHANGE ME] Re-generated to pick up changes from source1.",
            "",
        ),
        call.push_changes().add_labels(["context: partial"]),
        call.check_if_pr_already_exists("test-source2"),
        call.push_changes(
            1,
            "test-source2",
            "[CHANGE ME] Re-generated to pick up changes from source2.",
            "",
        ),
        call.push_changes().add_labels(["context: partial"]),
    ]
    assert golden_calls == calls
コード例 #2
0
def test_synthesize_loop_skips_multiple_existing_prs(
    synthesize_loop_fixture: SynthesizeLoopFixture, ):
    change_history = [
        [WriteFile("a.txt", "a")],
        [WriteFile("b.txt", "b")],
    ]
    source_versions = compile_histories(change_history,
                                        synthesize_loop_fixture.synthesizer)
    # Call synthesize_loop.
    synthesize_loop_fixture.change_pusher.check_if_pr_already_exists.return_value = True
    synthesize_loop_fixture.synthesize_loop(source_versions, True)
    calls = synthesize_loop_fixture.change_pusher.mock_calls
    golden_calls = [
        call.check_if_pr_already_exists("test-source1"),
        call.check_if_pr_already_exists("test-source2"),
    ]
    assert golden_calls == calls
コード例 #3
0
def test_synthesize_loop_uses_single_commit_title_for_pr_title(
    synthesize_loop_fixture: SynthesizeLoopFixture, ):
    change_history = [
        [NoChange()],
        [NoChange(), WriteFile("a.txt", "a")],
    ]
    source_versions = compile_histories(change_history,
                                        synthesize_loop_fixture.synthesizer)
    # Call synthesize_loop.
    synthesize_loop_fixture.synthesize_loop(source_versions, True)
    calls = synthesize_loop_fixture.change_pusher.mock_calls
    golden_calls = [
        call.check_if_pr_already_exists("test-source1"),
        call.check_if_pr_already_exists("test-source2"),
        call.push_changes(1, "test-source2", "Wrote a to a.txt."),
        call.push_changes().add_labels(["context: full"]),
    ]
    assert golden_calls == calls