import shutil
from utils import (
cargo_run,
goto_root,
mk_and_cd_tmp_dir,
rand_word,
write_string,
)
def summary():
goto_root()
mk_and_cd_tmp_dir()
cargo_run(["init"])
cargo_run(["config", "--set", "model", "dummy"])
cargo_run(["config", "--set", "summary_after_build", "false"])
uid_empty = get_uid()
cargo_run(["summary"])
cargo_run(["check"])
assert uid_empty != get_uid()
write_string("a.txt", "Hello, World!")
cargo_run(["add", "a.txt"])
cargo_run(["build"])
assert cargo_run(["summary", "--cached"], check=False) != 0
cargo_run(["check"])
uid_without_summary = get_uid()
cargo_run(["summary", "--remove"])
cargo_run(["check"])
assert uid_without_summary == get_uid()
cargo_run(["summary"])
cargo_run(["check"])
assert uid_without_summary != get_uid()
uid_with_dummy_summary = get_uid()
dummy_summary = get_summary()
rand_summary = rand_word()
cargo_run(["summary", "--set", rand_summary])
cargo_run(["check"])
assert uid_with_dummy_summary != get_uid()
assert dummy_summary != get_summary()
uid_with_rand_summary = get_uid()
assert rand_summary == get_summary()
assert uid_with_rand_summary == get_uid()
assert rand_summary == get_summary()
cargo_run(["summary", "--force"])
cargo_run(["check"])
assert uid_with_rand_summary != get_uid()
assert rand_summary != get_summary()
cargo_run(["summary", "--remove"])
cargo_run(["check"])
assert uid_without_summary == get_uid()
assert cargo_run(["summary", "--cached"], check=False) != 0
cargo_run(["summary", "--set", "whatever"])
cargo_run(["config", "--set", "summary_after_build", "true"])
cargo_run(["build"])
cargo_run(["summary", "--cached"])
cargo_run(["summary", "--remove"])
cargo_run(["build"])
cargo_run(["summary", "--cached"])
write_string("b.txt", "Hello, World!!")
shutil.copyfile("../tests/images/red.jpg", "invalid-utf8.txt")
cargo_run(["add", "invalid-utf8.txt"])
cargo_run(["add", "b.txt"])
cargo_run(["build"])
assert cargo_run(["summary", "--cached"], check=False) != 0
def get_uid():
return cargo_run(["uid"], stdout=True).strip()
def get_summary():
return cargo_run(["summary"], stdout=True).strip()