def test_auto_header(): roots = [ Path(SAMPLE, name) for name in ('cmake', 'include', 'scripts', 'src', 'build.sh', 'CMakeLists.txt', 'readme.md') ] auto_header = copywriter.Copywriter(*roots).auto_header assert auto_header == 'Copyright {year} Bob'
def test_outdated_headers_are_found(): roots = [ Path(SAMPLE, name) for name in ('cmake', 'include', 'scripts', 'src', 'build.sh', 'CMakeLists.txt', 'readme.md') ] found = copywriter.Copywriter(*roots).outdated expected = { Path(SAMPLE, 'scripts', 'baz.py'), Path(SAMPLE, 'src', 'bar.c'), } assert found == expected
def test_missing_headers_are_found(): roots = [ Path(SAMPLE, name) for name in ('cmake', 'include', 'scripts', 'src', 'build.sh', 'CMakeLists.txt', 'readme.md') ] found = copywriter.Copywriter(*roots).missing expected = { Path(SAMPLE, 'include', 'nested_dir', 'foo.h'), Path(SAMPLE, 'src', 'CMakeLists.txt'), } assert found == expected
def test_find_files(): roots = [ Path(SAMPLE, name) for name in ('cmake', 'include', 'scripts', 'src', 'build.sh', 'CMakeLists.txt', 'readme.md') ] found = copywriter.Copywriter(*roots).files expected = { Path(SAMPLE, 'cmake', 'bar.cmake'), Path(SAMPLE, 'include', 'nested_dir', 'bar.h'), Path(SAMPLE, 'include', 'nested_dir', 'foo.h'), Path(SAMPLE, 'scripts', 'baz.py'), Path(SAMPLE, 'scripts', 'foo.py'), Path(SAMPLE, 'src', 'bar.c'), Path(SAMPLE, 'src', 'CMakeLists.txt'), Path(SAMPLE, 'src', 'foo.c'), Path(SAMPLE, 'build.sh'), Path(SAMPLE, 'CMakeLists.txt'), } assert found == expected
def test_add_succeeds(tmp_path): test_source_path = Path(tmp_path, 'test_sources') shutil.copytree(src=ROOT, dst=test_source_path) copywriter.Copywriter(test_source_path).add_missing()
def test_update_succeeds(tmp_path): test_source_path = Path(tmp_path, 'test_sources') shutil.copytree(src=ROOT, dst=test_source_path) copywriter.Copywriter(test_source_path).update()
def test_show_succeeds(tmp_path): test_source_path = Path(tmp_path, 'test_sources') shutil.copytree(src=ROOT, dst=test_source_path) writer = copywriter.Copywriter(test_source_path)