transplant file test (compact) on folders

This commit is contained in:
Norwid Behrnd 2021-09-29 09:43:26 +00:00
parent 6dfe900beb
commit 72c8274385
2 changed files with 78 additions and 2 deletions

View file

@ -309,3 +309,40 @@ def test_folder_pattern_default(arg1, name=TFOLDER):
assert os.path.isdir(new) # presence stamped folder assert os.path.isdir(new) # presence stamped folder
os.rmdir(new) os.rmdir(new)
assert os.path.isdir(new) is False # space cleaning assert os.path.isdir(new) is False # space cleaning
@pytest.mark.folders
@pytest.mark.compact
@pytest.mark.parametrize("arg1", ["-C", "--compact",
"-C -d", "--compact -d",
"-C --directories", "--compact --directories",
"-C -m", "--compact -m",
"-C --mtime", "--compact --mtime",
"-C -c", "--compact -c",
"-C --ctime", "--compact --ctime"])
def test_folder_pattern_compact(arg1, name=TFOLDER):
"""Prepend 'YYYYMMDD_' to the folder name."""
prepare_testfolder(name)
day = str("")
new = str("")
if arg1 in ["-C", "--compact",
"-C -d", "--compact -d",
"-C --directories", "--compact --directories",
"-C -m", "--compact -m",
"-C --mtime", "--compact --mtime"]:
day = query_modification_time(name).split()[0]
elif arg1 in ["-C -c", "--compact -c",
"-C --ctime", "--compact --ctime"]:
day = query_creation_time(name).split()[0]
# drop the hyphens in the datestamp:
day = day.replace("-", "")
new = "_".join([day, name])
test = getoutput(f"python3 {PROGRAM} {name} {arg1}")
assert os.path.isdir(name) is False # absence unstamped folder
assert os.path.isdir(new) # presence stamped folder
os.rmdir(new)
assert os.path.isdir(new) is False # space cleaning

View file

@ -467,7 +467,7 @@
assert os.path.isfile("test.txt") is False assert os.path.isfile("test.txt") is False
#+end_src #+end_src
*** perform the tests on folders [1/6] *** perform the tests on folders [2/6]
At present, most of the instructions already defined and used in section At present, most of the instructions already defined and used in section
"test on files" is repeated with small adjustments for checking date2name's "test on files" is repeated with small adjustments for checking date2name's
@ -502,7 +502,46 @@
assert os.path.isdir(new) is False # space cleaning assert os.path.isdir(new) is False # space cleaning
#+end_src #+end_src
+ [ ] compact pattern, YYYYMMDD_ prepended + [X] compact pattern, YYYYMMDD_ prepended
#+begin_src python :tangle test_date2name.py
@pytest.mark.folders
@pytest.mark.compact
@pytest.mark.parametrize("arg1", ["-C", "--compact",
"-C -d", "--compact -d",
"-C --directories", "--compact --directories",
"-C -m", "--compact -m",
"-C --mtime", "--compact --mtime",
"-C -c", "--compact -c",
"-C --ctime", "--compact --ctime"])
def test_folder_pattern_compact(arg1, name=TFOLDER):
"""Prepend 'YYYYMMDD_' to the folder name."""
prepare_testfolder(name)
day = str("")
new = str("")
if arg1 in ["-C", "--compact",
"-C -d", "--compact -d",
"-C --directories", "--compact --directories",
"-C -m", "--compact -m",
"-C --mtime", "--compact --mtime"]:
day = query_modification_time(name).split()[0]
elif arg1 in ["-C -c", "--compact -c",
"-C --ctime", "--compact --ctime"]:
day = query_creation_time(name).split()[0]
# drop the hyphens in the datestamp:
day = day.replace("-", "")
new = "_".join([day, name])
test = getoutput(f"python3 {PROGRAM} {name} {arg1}")
assert os.path.isdir(name) is False # absence unstamped folder
assert os.path.isdir(new) # presence stamped folder
os.rmdir(new)
assert os.path.isdir(new) is False # space cleaning
#+end_src
+ [ ] month pattern, YYYY-MM_ prepended + [ ] month pattern, YYYY-MM_ prepended