mirror of
https://github.com/novoid/date2name.git
synced 2026-02-17 13:17:30 +00:00
Adjust present test functions to file.
The present test functions act on files only. Early tests to stack folders on top of the present functions do not work reliably yet. Thus, better to name the functions (uniformly) about what they test which are actions on files only. This change equally prevents some line breaks on the CLI, too.
This commit is contained in:
parent
20fbfe2504
commit
d1f5672db0
2 changed files with 28 additions and 28 deletions
|
|
@ -77,7 +77,7 @@ def test_script_version():
|
|||
@pytest.mark.parametrize("arg1", [" ", "-f", "--files",
|
||||
"-m", "--mtime",
|
||||
"-c", "--ctime"])
|
||||
def test_default_pattern_YYYY_MM_DD(arg1):
|
||||
def test_file_pattern_default(arg1):
|
||||
"""Prepend 'YYYY-MM-DD_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
|
|
@ -101,7 +101,7 @@ def test_default_pattern_YYYY_MM_DD(arg1):
|
|||
"-C --mtime", "--compact --mtime",
|
||||
"-C -c", "--compact -c",
|
||||
"-C --ctime", "--compact --ctime"])
|
||||
def test_compact_pattern_YYYYMMDD(arg1):
|
||||
def test_file_pattern_compact(arg1):
|
||||
"""Prepend 'YYYYMMDD_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
|
|
@ -133,7 +133,7 @@ def test_compact_pattern_YYYYMMDD(arg1):
|
|||
"-M --mtime", "--month --mtime",
|
||||
"-M -c", "--month -c",
|
||||
"-M --ctime", "--month --ctime"])
|
||||
def test_compact_month_YYYY_MM(arg1):
|
||||
def test_file_pattern_month(arg1):
|
||||
"""Prepend 'YYYY-MM_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
|
|
@ -164,7 +164,7 @@ def test_compact_month_YYYY_MM(arg1):
|
|||
"--withtime -m", "--withtime --mtime",
|
||||
"-w -c", "-w --ctime",
|
||||
"--withtime -c", "--withtime --ctime"])
|
||||
def test_default_pattern_YYYY_MM_DDThh_mm_ss(arg1):
|
||||
def test_file_pattern_withtime(arg1):
|
||||
"""Prepend 'YYYY-MM-DDThh.mm.ss_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
|
|
@ -198,7 +198,7 @@ def test_default_pattern_YYYY_MM_DDThh_mm_ss(arg1):
|
|||
"-S --mtime", "--short --mtime",
|
||||
"-S -c", "--short -c",
|
||||
"-S --ctime", "--short --ctime"])
|
||||
def test_short_pattern_YYMMDD(arg1):
|
||||
def test_file_pattern_short(arg1):
|
||||
"""Prepend 'YYMMDD_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
|
|
@ -228,7 +228,7 @@ def test_short_pattern_YYMMDD(arg1):
|
|||
@pytest.mark.parametrize("arg1", ["default", "short", "compact",
|
||||
"month", "withtime"])
|
||||
@pytest.mark.parametrize("arg2", ["-r", "--remove"])
|
||||
def test_remove_stamp(arg1, arg2):
|
||||
def test_file_remove_stamp(arg1, arg2):
|
||||
"""Check the retraction of the leading time stamp."""
|
||||
substitution = {"default" : "2021-09-21",
|
||||
"short" : "210921",
|
||||
|
|
|
|||
|
|
@ -187,18 +187,18 @@
|
|||
@pytest.mark.parametrize("arg1", [" ", "-f", "--files",
|
||||
"-m", "--mtime",
|
||||
"-c", "--ctime"])
|
||||
def test_default_pattern_YYYY_MM_DD(arg1):
|
||||
def test_file_pattern_default(arg1):
|
||||
"""Prepend 'YYYY-MM-DD_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
new = str("")
|
||||
|
||||
|
||||
if arg1 in [" ", "-f", "--files", "-m", "--mtime"]:
|
||||
day = query_modification_time().split()[0]
|
||||
|
||||
|
||||
elif arg1 in ["-c", "--ctime"]:
|
||||
day = query_creation_time().split()[0]
|
||||
|
||||
|
||||
new = "_".join([day, TFILE])
|
||||
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg1}")
|
||||
assert os.path.isfile(new)
|
||||
|
|
@ -216,26 +216,26 @@
|
|||
"-C --mtime", "--compact --mtime",
|
||||
"-C -c", "--compact -c",
|
||||
"-C --ctime", "--compact --ctime"])
|
||||
def test_compact_pattern_YYYYMMDD(arg1):
|
||||
def test_file_pattern_compact(arg1):
|
||||
"""Prepend 'YYYYMMDD_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
new = str("")
|
||||
|
||||
|
||||
if arg1 in ["-C", "--compact",
|
||||
"-C -f", "--compact -f",
|
||||
"-C --files", "--compact --files",
|
||||
"-C -m", "--compact -m",
|
||||
"-C --mtime", "--compact --mtime"]:
|
||||
day = query_modification_time().split()[0]
|
||||
|
||||
|
||||
elif arg1 in ["-C -c", "--compact -c",
|
||||
"-C --ctime", "--compact --ctime"]:
|
||||
day = query_creation_time().split()[0]
|
||||
|
||||
|
||||
# drop the hyphens in the datestamp:
|
||||
day = day.replace("-", "")
|
||||
|
||||
|
||||
new = "_".join([day, TFILE])
|
||||
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg1}")
|
||||
assert os.path.isfile(new)
|
||||
|
|
@ -253,26 +253,26 @@
|
|||
"-M --mtime", "--month --mtime",
|
||||
"-M -c", "--month -c",
|
||||
"-M --ctime", "--month --ctime"])
|
||||
def test_compact_month_YYYY_MM(arg1):
|
||||
def test_file_pattern_month(arg1):
|
||||
"""Prepend 'YYYY-MM_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
new = str("")
|
||||
|
||||
|
||||
if arg1 in ["-M", "--month",
|
||||
"-M -f", "--month -f",
|
||||
"-M --files", "--month --files",
|
||||
"-M -m", "--month -m",
|
||||
"-M --mtime", "--month --mtime"]:
|
||||
day = query_modification_time().split()[0]
|
||||
|
||||
|
||||
elif arg1 in ["-M -c", "--month -c",
|
||||
"-M --ctime", "--month --ctime"]:
|
||||
day = query_creation_time().split()[0]
|
||||
|
||||
|
||||
# trim off the last three characters in the datestamp:
|
||||
day = day[:-3]
|
||||
|
||||
|
||||
new = "_".join([day, TFILE])
|
||||
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg1}")
|
||||
assert os.path.isfile(new)
|
||||
|
|
@ -288,29 +288,29 @@
|
|||
"--withtime -m", "--withtime --mtime",
|
||||
"-w -c", "-w --ctime",
|
||||
"--withtime -c", "--withtime --ctime"])
|
||||
def test_default_pattern_YYYY_MM_DDThh_mm_ss(arg1):
|
||||
def test_file_pattern_withtime(arg1):
|
||||
"""Prepend 'YYYY-MM-DDThh.mm.ss_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
new = str("")
|
||||
|
||||
|
||||
if arg1 in ["-w -f", "-w --files",
|
||||
"--withtime -f", "--withtime --files",
|
||||
"-w -m", "-w --mtime",
|
||||
"--withtime -m", "--withtime --mtime"]:
|
||||
day = query_modification_time().split()[0]
|
||||
second = query_modification_time().split()[1]
|
||||
|
||||
|
||||
elif arg1 in ["-w -c", "-w --ctime",
|
||||
"--withtime -c", "--withtime --ctime"]:
|
||||
day = query_creation_time().split()[0]
|
||||
second = query_creation_time().split()[1]
|
||||
|
||||
|
||||
second = second.split(".")[0] # use integer seconds only
|
||||
second = second.replace(":", ".") # adjust representation
|
||||
|
||||
|
||||
new = "".join([day, "T", second, "_", TFILE])
|
||||
|
||||
|
||||
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg1}")
|
||||
assert os.path.isfile(new)
|
||||
os.remove(new)
|
||||
|
|
@ -327,7 +327,7 @@
|
|||
"-S --mtime", "--short --mtime",
|
||||
"-S -c", "--short -c",
|
||||
"-S --ctime", "--short --ctime"])
|
||||
def test_short_pattern_YYMMDD(arg1):
|
||||
def test_file_pattern_short(arg1):
|
||||
"""Prepend 'YYMMDD_' to the file name."""
|
||||
prepare_testfile()
|
||||
day = str("")
|
||||
|
|
@ -368,7 +368,7 @@
|
|||
@pytest.mark.parametrize("arg1", ["default", "short", "compact",
|
||||
"month", "withtime"])
|
||||
@pytest.mark.parametrize("arg2", ["-r", "--remove"])
|
||||
def test_remove_stamp(arg1, arg2):
|
||||
def test_file_remove_stamp(arg1, arg2):
|
||||
"""Check the retraction of the leading time stamp."""
|
||||
substitution = {"default" : "2021-09-21",
|
||||
"short" : "210921",
|
||||
|
|
|
|||
Loading…
Reference in a new issue