mirror of
https://github.com/novoid/date2name.git
synced 2026-02-16 21:04:17 +00:00
transplant file test (month) on folders
This commit is contained in:
parent
72c8274385
commit
ec1a3ccf2b
2 changed files with 77 additions and 3 deletions
|
|
@ -346,3 +346,40 @@ def test_folder_pattern_compact(arg1, name=TFOLDER):
|
|||
assert os.path.isdir(new) # presence stamped folder
|
||||
os.rmdir(new)
|
||||
assert os.path.isdir(new) is False # space cleaning
|
||||
|
||||
@pytest.mark.folders
|
||||
@pytest.mark.month
|
||||
@pytest.mark.parametrize("arg1", ["-M", "--month",
|
||||
"-M -d", "--month -d",
|
||||
"-M --directories", "--month --directories",
|
||||
"-M -m", "--month -m",
|
||||
"-M --mtime", "--month --mtime",
|
||||
"-M -c", "--month -c",
|
||||
"-M --ctime", "--month --ctime"])
|
||||
def test_file_pattern_month(arg1, name=TFOLDER):
|
||||
"""Prepend 'YYYY-MM_' to the file name."""
|
||||
prepare_testfolder(name)
|
||||
day = str("")
|
||||
new = str("")
|
||||
|
||||
if arg1 in ["-M", "--month",
|
||||
"-M -d", "--month -d",
|
||||
"-M --directories", "--month --directories",
|
||||
"-M -m", "--month -m",
|
||||
"-M --mtime", "--month --mtime"]:
|
||||
day = query_modification_time(name).split()[0]
|
||||
|
||||
elif arg1 in ["-M -c", "--month -c",
|
||||
"-M --ctime", "--month --ctime"]:
|
||||
day = query_creation_time(name).split()[0]
|
||||
|
||||
# trim off the last three characters in the datestamp:
|
||||
day = day[:-3]
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@
|
|||
assert os.path.isfile("test.txt") is False
|
||||
#+end_src
|
||||
|
||||
*** perform the tests on folders [2/6]
|
||||
*** perform the tests on folders [3/6]
|
||||
|
||||
At present, most of the instructions already defined and used in section
|
||||
"test on files" is repeated with small adjustments for checking date2name's
|
||||
|
|
@ -540,10 +540,47 @@
|
|||
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
|
||||
+ [X] month pattern, YYYY-MM_ prepended
|
||||
#+begin_src python :tangle test_date2name.py
|
||||
@pytest.mark.folders
|
||||
@pytest.mark.month
|
||||
@pytest.mark.parametrize("arg1", ["-M", "--month",
|
||||
"-M -d", "--month -d",
|
||||
"-M --directories", "--month --directories",
|
||||
"-M -m", "--month -m",
|
||||
"-M --mtime", "--month --mtime",
|
||||
"-M -c", "--month -c",
|
||||
"-M --ctime", "--month --ctime"])
|
||||
def test_file_pattern_month(arg1, name=TFOLDER):
|
||||
"""Prepend 'YYYY-MM_' to the file name."""
|
||||
prepare_testfolder(name)
|
||||
day = str("")
|
||||
new = str("")
|
||||
|
||||
if arg1 in ["-M", "--month",
|
||||
"-M -d", "--month -d",
|
||||
"-M --directories", "--month --directories",
|
||||
"-M -m", "--month -m",
|
||||
"-M --mtime", "--month --mtime"]:
|
||||
day = query_modification_time(name).split()[0]
|
||||
|
||||
elif arg1 in ["-M -c", "--month -c",
|
||||
"-M --ctime", "--month --ctime"]:
|
||||
day = query_creation_time(name).split()[0]
|
||||
|
||||
# trim off the last three characters in the datestamp:
|
||||
day = day[:-3]
|
||||
|
||||
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
|
||||
|
||||
+ [ ] short pattern, YYMMDD_ prepended
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue