Files
photo-dater/pytest/test_file_paths.py

37 lines
1.1 KiB
Python

import os
import pytest
import random
from helpers import *
from fixtures import *
cmd = 'python3 updatescannedpics.py'
def test_file_path(log_file):
command = f'{cmd}'
run_successfull_cmd(command)
with open(log_file, 'r') as my_log:
lines = my_log.readlines()
assert "Input Dir = ." in lines[0]
assert "Output Dir = ." in lines[1]
assert "Not Using pre formated directories" in lines[2]
@pytest.mark.parametrize("option, log_start", [("-i", "Input Dir = "), ("--indir", "Input Dir = "), ("-o", "Output Dir = "), ("--outdir", "Output Dir = ")])
@pytest.mark.parametrize("in_dir_start", ["", "./", "/", "../"])
def test_set_indir(option, log_start, in_dir_start, log_file):
indir_name = gen_rand_name(12)
command = f'{cmd} {option} {in_dir_start}{indir_name}'
run_successfull_cmd(command)
expected_start = in_dir_start
if len(in_dir_start) == 0:
expected_start = './'
expected_file_path = f"{log_start}{expected_start}{indir_name}"
assert check_log_string(log_file, expected_file_path)