You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# After fixing the TODO about adding new lines, set this back to "new content"
)
deftest_server_back_syncs_changes_from_project_to_template_with_subdir_copier(
copier_output_subdir_template_repo: Repo,
):
template_path=Path(copier_output_subdir_template_repo.working_dir)
template_output_path=template_path/"output"folder_name="project"project_path=GENERATED_FILES_DIR/folder_nameexpect_file=project_path/"a1.txt"template_file=template_output_path/"{{ q1 }}.txt.jinja"non_templated_template_file=template_output_path/"README.md"non_templated_expect_file=project_path/"README.md"config=FlexlateDevConfig()
withrun_server(
config, None, template_path, GENERATED_FILES_DIR, no_input=True, back_sync=True
) ascontext:
project_repo=Repo(project_path)
wait_until_path_exists(expect_file)
# Check initial loadassertexpect_file.read_text() =="1"templated_modified_time=expect_file.lstat().st_mtimeassertnon_templated_expect_file.read_text() =="some existing content"assertnon_templated_template_file.read_text() =="some existing content"non_templated_modified_time=non_templated_template_file.lstat().st_mtime# Cause a back syncnon_templated_expect_file.write_text("new content")
stage_and_commit_all(project_repo, "Trigger back sync")
# Check back syncwait_until_file_has_content(
# After fixing the TODO about adding new lines, set this back to "new content"non_templated_template_file,
non_templated_modified_time,
"new content\n",
)
wait_until_returns_true(
lambda: notcontext.is_back_syncing, "Back sync is still running"
)
# Cause a reloadtemplate_file.write_text("new content {{ q2 }}")
# Check reloadwait_until_file_has_content(
expect_file, templated_modified_time, "new content 1"
)
deftest_server_does_not_back_sync_a_forward_sync_change(
copier_one_template_repo: Repo,
):
template_path=Path(copier_one_template_repo.working_dir)
folder_name="project"project_path=GENERATED_FILES_DIR/folder_nameexpect_file=project_path/"a1.txt"non_templated_template_file=template_path/"README.md"non_templated_expect_file=project_path/"README.md"config=FlexlateDevConfig()
withrun_server(
config, None, template_path, GENERATED_FILES_DIR, no_input=True, back_sync=True
) ascontext:
template_repo=Repo(template_path)
wait_until_path_exists(expect_file)
# Check initial loadassertexpect_file.read_text() =="1"assertnon_templated_expect_file.read_text() =="some existing content"assertnon_templated_template_file.read_text() =="some existing content"non_templated_expect_modified_time=non_templated_expect_file.lstat().st_mtime# Check the most recent commit on the template repo. It should not change after forward synclast_commit_sha=template_repo.head.commit.hexsha# Cause a forward-syncnon_templated_template_file.write_text("new content")
# Check forward syncwait_until_file_has_content(
non_templated_expect_file,
non_templated_expect_modified_time,
"new content",
)
# Wait for back-sync to finish sleeping, so it has a chance to runwait_until_returns_true(
lambda: notcontext.back_sync_is_sleeping, "Back sync is still sleeping"
)
# Wait another half second so that back-sync definitely would have run if it was going totime.sleep(0.5)
# Give time for potential back-sync to completewait_until_returns_true(
lambda: notcontext.is_back_syncing, "Back sync is still running"
)
# Last commit on template repo should not have changed after back-syncasserttemplate_repo.head.commit.hexsha==last_commit_sha# TODO: add tests for back sync cookiecutter# TODO: add tests for auto-commit, need to set up temp git repos
c2cb6557dd0c25c1bc1dfd92638bca1228cee9e7
The text was updated successfully, but these errors were encountered:
about adding new lines, set this back to "new content"
flexlate-dev/tests/test_server.py
Line 377 in 42ed46b
c2cb6557dd0c25c1bc1dfd92638bca1228cee9e7
The text was updated successfully, but these errors were encountered: