コード例 #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_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
コード例 #3
0
def test_synthesize_loop_track_obsolete_files(
    synthesize_loop_fixture: SynthesizeLoopFixture, ):
    # Create a synth.metadata with empty generatedFiles.
    metadata = {"generatedFiles": []}
    with open("synth.metadata", "wt") as synth_metadata:
        synth_metadata.write(json.dumps(metadata))
    git.commit_all_changes("Added synth.metadata with empty generatedFiles.")

    # Create a generated change that populate synth.metadata's generatedFiles.
    metadata = {"generatedFiles": ["a.txt"]}
    write_metadata = WriteFile("synth.metadata", json.dumps(metadata))

    # Invoke the synthesize loop.
    change_history = [[NoChange(), write_metadata]]
    source_versions = compile_histories(change_history,
                                        synthesize_loop_fixture.synthesizer)
    synthesize_loop_fixture.synthesize_loop(source_versions)

    # Confirm the synth loop pushed a change.
    calls = synthesize_loop_fixture.change_pusher.mock_calls
    assert call.push_changes(1, "test",
                             "chore: start tracking obsolete files") in calls