44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
|
|
import pytest
|
|
import random
|
|
import string
|
|
import subprocess
|
|
|
|
from helpers import *
|
|
from fixtures import *
|
|
|
|
cmd = 'python3 updatescannedpics.py'
|
|
|
|
@pytest.mark.parametrize("cmd_line", ["-h", "--help"])
|
|
def test_help(cmd_line):
|
|
command = f'{cmd} {cmd_line}'.split()
|
|
output = subprocess.run(command, capture_output=True, encoding='UTF-8')
|
|
|
|
assert output.returncode == 1
|
|
assert output.stdout == "-i Input Directory\n-o Output Directory\n-m My Pre-Configured Directory Layout\nDefaults directory to PWD\n"
|
|
|
|
def test_bad_param():
|
|
bad_options = [char for char in string.ascii_letters]
|
|
bad_options.remove('h')
|
|
bad_options.remove('i')
|
|
bad_options.remove('o')
|
|
bad_options.remove('m')
|
|
|
|
rand_bad_opt = random.choice(bad_options)
|
|
command = f'{cmd} -{rand_bad_opt}'.split()
|
|
output = subprocess.run(command, capture_output=True, encoding='UTF-8')
|
|
|
|
assert output.returncode == 2
|
|
assert output.stdout == f"option -{rand_bad_opt} not recognized\n-i Input Directory\n-o Output Directory\n-m My Pre-Configured Directory Layout\nDefaults directory to PWD\n"
|
|
|
|
@pytest.mark.parametrize("cmd_line, expected", [("", "Not Using"), ("-m", "Using")])
|
|
def test_my_format(cmd_line, expected, log_file):
|
|
command = f'{cmd} {cmd_line}'
|
|
run_successfull_cmd(command)
|
|
|
|
with open(log_file, 'r') as my_log:
|
|
lines = my_log.readlines()
|
|
assert f"{expected} pre formated directories" in lines[2]
|
|
|
|
|