MCPcopy
hub / github.com/copier-org/copier / test_user_defaults_updated

Function test_user_defaults_updated

tests/test_config.py:647–705  ·  view source on GitHub ↗
(
    tmp_path_factory: pytest.TempPathFactory,
    user_defaults_initial: AnyByStrDict,
    user_defaults_updated: AnyByStrDict,
    data_initial: AnyByStrDict,
    data_updated: AnyByStrDict,
    settings_defaults: AnyByStrDict,
    expected_initial: str,
    expected_updated: str,
    settings_path: Path,
)

Source from the content-addressed store, hash-verified

645 ],
646)
647def test_user_defaults_updated(
648 tmp_path_factory: pytest.TempPathFactory,
649 user_defaults_initial: AnyByStrDict,
650 user_defaults_updated: AnyByStrDict,
651 data_initial: AnyByStrDict,
652 data_updated: AnyByStrDict,
653 settings_defaults: AnyByStrDict,
654 expected_initial: str,
655 expected_updated: str,
656 settings_path: Path,
657) -> None:
658 src, dst = map(tmp_path_factory.mktemp, ("src", "dst"))
659 with local.cwd(src):
660 build_file_tree(
661 {
662 (src / "copier.yaml"): (
663 """\
664 a_string:
665 default: lorem ipsum
666 type: str
667 """
668 ),
669 (src / "user_data.txt.jinja"): (
670 """\
671 A string: {{ a_string }}
672 """
673 ),
674 (src / "{{ _copier_conf.answers_file }}.jinja"): (
675 """\
676 # Changes here will be overwritten by Copier
677 {{ _copier_answers|to_nice_yaml }}
678 """
679 ),
680 }
681 )
682 git_init()
683 settings_path.write_text(f"defaults: {json.dumps(settings_defaults)}")
684
685 copier.run_copy(
686 str(src),
687 dst,
688 defaults=True,
689 overwrite=True,
690 user_defaults=user_defaults_initial,
691 data=data_initial,
692 )
693 assert (dst / "user_data.txt").read_text() == expected_initial
694
695 with local.cwd(dst):
696 git_init()
697
698 copier.run_update(
699 dst,
700 defaults=True,
701 overwrite=True,
702 user_defaults=user_defaults_updated,
703 data=data_updated,
704 )

Callers

nothing calls this directly

Calls 4

build_file_treeFunction · 0.85
git_initFunction · 0.85
run_copyMethod · 0.80
run_updateMethod · 0.80

Tested by

no test coverage detected