forked from Github/date2name
transplant file test (withtime) on folders
This commit is contained in:
parent
765179c2a1
commit
d630277ed6
2 changed files with 79 additions and 2 deletions
|
|
@ -422,3 +422,41 @@ def test_folder_pattern_short(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.withtime
|
||||
@pytest.mark.parametrize("arg1", ["-w -d", "-w --directories",
|
||||
"--withtime -d", "--withtime --directories",
|
||||
"-w -m", "-w --mtime",
|
||||
"--withtime -m", "--withtime --mtime",
|
||||
"-w -c", "-w --ctime",
|
||||
"--withtime -c", "--withtime --ctime"])
|
||||
def test_file_pattern_withtime(arg1, name=TFOLDER):
|
||||
"""Prepend 'YYYY-MM-DDThh.mm.ss_' to the folder name."""
|
||||
prepare_testfolder(name)
|
||||
day = str("")
|
||||
new = str("")
|
||||
|
||||
if arg1 in ["-w -d", "-w --directories",
|
||||
"--withtime -d", "--withtime --directories",
|
||||
"-w -m", "-w --mtime",
|
||||
"--withtime -m", "--withtime --mtime"]:
|
||||
day = query_modification_time(name).split()[0]
|
||||
second = query_modification_time(name).split()[1]
|
||||
|
||||
elif arg1 in ["-w -c", "-w --ctime",
|
||||
"--withtime -c", "--withtime --ctime"]:
|
||||
day = query_creation_time(name).split()[0]
|
||||
second = query_creation_time(name).split()[1]
|
||||
|
||||
second = second.split(".")[0] # use integer seconds only
|
||||
second = second.replace(":", ".") # adjust representation
|
||||
|
||||
new = "".join([day, "T", second, "_", 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 [4/6]
|
||||
*** perform the tests on folders [5/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
|
||||
|
|
@ -624,7 +624,46 @@
|
|||
assert os.path.isdir(new) is False # space cleaning
|
||||
#+end_src
|
||||
|
||||
+ [ ] withtime pattern, YYYY-MM-DDThh.mm.ss_ prepended
|
||||
+ [X] withtime pattern, YYYY-MM-DDThh.mm.ss_ prepended
|
||||
#+begin_src python :tangle test_date2name.py
|
||||
@pytest.mark.folders
|
||||
@pytest.mark.withtime
|
||||
@pytest.mark.parametrize("arg1", ["-w -d", "-w --directories",
|
||||
"--withtime -d", "--withtime --directories",
|
||||
"-w -m", "-w --mtime",
|
||||
"--withtime -m", "--withtime --mtime",
|
||||
"-w -c", "-w --ctime",
|
||||
"--withtime -c", "--withtime --ctime"])
|
||||
def test_file_pattern_withtime(arg1, name=TFOLDER):
|
||||
"""Prepend 'YYYY-MM-DDThh.mm.ss_' to the folder name."""
|
||||
prepare_testfolder(name)
|
||||
day = str("")
|
||||
new = str("")
|
||||
|
||||
if arg1 in ["-w -d", "-w --directories",
|
||||
"--withtime -d", "--withtime --directories",
|
||||
"-w -m", "-w --mtime",
|
||||
"--withtime -m", "--withtime --mtime"]:
|
||||
day = query_modification_time(name).split()[0]
|
||||
second = query_modification_time(name).split()[1]
|
||||
|
||||
elif arg1 in ["-w -c", "-w --ctime",
|
||||
"--withtime -c", "--withtime --ctime"]:
|
||||
day = query_creation_time(name).split()[0]
|
||||
second = query_creation_time(name).split()[1]
|
||||
|
||||
second = second.split(".")[0] # use integer seconds only
|
||||
second = second.replace(":", ".") # adjust representation
|
||||
|
||||
new = "".join([day, "T", second, "_", 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
|
||||
|
||||
+ [ ] retraction of the date/time stamp
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue