예제 #1
0
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
예제 #2
0
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)
예제 #3
0
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
예제 #4
0
def test_write_to_existing_file():
    write_to_file(EMPTY_TEMP_FILE, TEMP_FILE_CONTENT)
    assert read_file(EMPTY_TEMP_FILE) == TEMP_FILE_CONTENT
예제 #5
0
def test_read_not_existing_file():
    with pytest.raises(IOError):
        read_file(NOT_EXISTING_FILE)
예제 #6
0
def test_read_existing_file():
    create_file(TEMP_FILE_WITH_CONTENT, TEMP_FILE_CONTENT)
    assert read_file(TEMP_FILE_WITH_CONTENT) == TEMP_FILE_CONTENT
예제 #7
0
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)