Initial commit to photo-dater with pytest test
This commit is contained in:
36
pytest/test_file_paths.py
Normal file
36
pytest/test_file_paths.py
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user