def test_copy_file_and_replace_keywords(): template = read_file(TEMPLATE_FILE) _copy_file_and_replace_keywords(BUILD_DESTINATION, template, KEYWORDS) assert path_exists(BUILD_DESTINATION) is True assert read_file(BUILD_DESTINATION) == EXPECTED_RESULT
def test_keyword_amount_does_not_match_template_fillers(): template = read_file(TEMPLATE_FILE) with pytest.raises(IndexError): _copy_file_and_replace_keywords(BUILD_DESTINATION, template, TOO_FEW_KEYWORDS) with pytest.raises(IndexError): _copy_file_and_replace_keywords(BUILD_DESTINATION, template, TOO_MANY_KEYWORDS)
def test_create_file(): create_file(TEMP_FILE_WITH_CONTENT, TEMP_FILE_CONTENT) assert path_exists(TEMP_FILE_WITH_CONTENT) is True assert read_file(TEMP_FILE_WITH_CONTENT) == TEMP_FILE_CONTENT
def test_write_to_existing_file(): write_to_file(EMPTY_TEMP_FILE, TEMP_FILE_CONTENT) assert read_file(EMPTY_TEMP_FILE) == TEMP_FILE_CONTENT
def test_read_not_existing_file(): with pytest.raises(IOError): read_file(NOT_EXISTING_FILE)
def test_read_existing_file(): create_file(TEMP_FILE_WITH_CONTENT, TEMP_FILE_CONTENT) assert read_file(TEMP_FILE_WITH_CONTENT) == TEMP_FILE_CONTENT
def copy_template_file_and_replace_keywords(src, dst, args): template = read_file(src) _create_parent_dir(dst) _copy_file_and_replace_keywords(dst, template, args)