def test_process_file_with_rename_should_remove_original_file(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_1_2_9_11_12_INPUT) process_file(input_file, OUTPUT_FILE_NAME, keep_input_file=False) assert os.listdir(input_file.dirname) == [OUTPUT_FILE_NAME]
def test_process_file_without_env_should_raise_error(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_3_10_INPUT) with pytest.raises(ValueError): process_file(input_file) input_file.remove()
def test_process_file_backup_file_deletion(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_1_2_9_11_12_INPUT) process_file(input_file) assert os.listdir(input_file.dirname) == [INPUT_FILE_NAME] input_file.remove()
def test_process_file_with_incorrect_fstring_syntax_2(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_7_INPUT) process_file(input_file) content = input_file.read() input_file.remove() assert content == TEST_CASE_7_OUTPUT
def test_process_file_with_multiple_fstrings(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_4_INPUT) process_file(input_file) content = input_file.read() input_file.remove() assert content == TEST_CASE_1_4_5_OUTPUT
def test_process_file_without_env(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_1_2_9_11_12_INPUT) process_file(input_file) content = input_file.read() input_file.remove() assert content == TEST_CASE_1_4_5_OUTPUT
def test_process_file_with_rename_should_not_remove_original_file(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_1_2_9_11_12_INPUT) process_file(input_file, OUTPUT_FILE_NAME) content = input_file.read() assert content == TEST_CASE_1_2_9_11_12_INPUT assert os.listdir( input_file.dirname) == [INPUT_FILE_NAME, OUTPUT_FILE_NAME]
def test_process_file_backup_if_exception_raised(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_3_10_INPUT) with pytest.raises(ValueError): process_file(input_file) content = input_file.read() input_file.remove() assert content == TEST_CASE_3_10_INPUT
def test_process_file_with_multiple_fstrings_on_different_strings(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_5_INPUT) os.environ['host'] = 'localhost' process_file(input_file) content = input_file.read() del os.environ['host'] input_file.remove() assert content == TEST_CASE_1_4_5_OUTPUT
def test_process_file_with_env(tmpdir): input_file = tmpdir.mkdir('tmp').join(INPUT_FILE_NAME) input_file.write(TEST_CASE_1_2_9_11_12_INPUT) os.environ['log_file_path'] = 'env_file.tmp' process_file(input_file) content = input_file.read() del os.environ['log_file_path'] input_file.remove() assert content == TEST_CASE_2_OUTPUT