error retracting tags, ticketed version

The development version on GitHub offers the option to retract
time stamps date2name prepended to the files' file names.  As this
version of the test script reveals, stamps obtained with the option
--withtime however are not fully reverted.  The finding was shared
with Karl Voit as an issue for date2name earlier today (2021-09-22)
for a cross check.
This commit is contained in:
Norwid Behrnd 2021-09-22 21:00:53 +00:00
parent 051254b9d6
commit 2e3654fd78
3 changed files with 73 additions and 2 deletions

0
Makefile Normal file → Executable file
View file

View file

@ -224,3 +224,33 @@ def test_short_pattern_YYMMDD(arg1):
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg1}")
assert os.path.isfile(new)
os.remove(new)
import time, os, sys
@pytest.mark.parametrize("arg1", ["default", "short", "compact", "month", "withtime"])
@pytest.mark.parametrize("arg2", ["-r", "--remove"])
def test_remove_stamp(arg1, arg2):
"""Check the retraction of the leading time stamp."""
substitution = {"default" : "2021-09-21",
"short" : "210921",
"compact" : "20210921",
"month" : "2021-09",
"withtime": "2021-09-21T13.59.59"}
prepend = substitution.get(arg1)
BASIS = "test.txt"
TFILE = ""
TFILE = "_".join([prepend, BASIS])
with open(TFILE, mode = "w") as newfile:
newfile.write("This is a test file.")
time.sleep(2)
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg2}")
time.sleep(2)
assert os.path.isfile(TFILE) is False # absence of stamped file
assert os.path.isfile(BASIS) # presence unstamped file
try:
os.remove("test.txt")
except OSError:
print("Running remove test, file 'test.txt' was not erased.")
sys.exit()

View file

@ -1,6 +1,6 @@
#+NAME: test_generator.org
#+AUTHOR: nbehrnd@yahoo.com
#+DATE: 2021-09-17 (YYYY-MM-DD)
#+DATE: 2021-09-22 (YYYY-MM-DD)
# License: GPL3, 2021.
#+PROPERTY: header-args :tangle yes
@ -176,7 +176,7 @@
#+end_src
*** perform the tests on files [5/5]
*** perform the tests on files [5/6]
These tests check the addition of a time stamp ahead of the file name.
@ -352,3 +352,44 @@
assert os.path.isfile(new)
os.remove(new)
#+end_src
+ [ ] Check the retraction of the date/time stamp
The test is constrained to the five fix formats prepending the file name.
/Not ready for inclusion into the main branch/ To trace the advancement of
pytest's processing, long delays are set. A manual check of date2time on
the CLI confirms that date2name writes the --withtime format, but is not
successful to retract this stamp.
#+begin_src python :tangle test_date2name.py
import time, os, sys
@pytest.mark.parametrize("arg1", ["default", "short", "compact", "month", "withtime"])
@pytest.mark.parametrize("arg2", ["-r", "--remove"])
def test_remove_stamp(arg1, arg2):
"""Check the retraction of the leading time stamp."""
substitution = {"default" : "2021-09-21",
"short" : "210921",
"compact" : "20210921",
"month" : "2021-09",
"withtime": "2021-09-21T13.59.59"}
prepend = substitution.get(arg1)
BASIS = "test.txt"
TFILE = ""
TFILE = "_".join([prepend, BASIS])
with open(TFILE, mode = "w") as newfile:
newfile.write("This is a test file.")
time.sleep(2)
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg2}")
time.sleep(2)
assert os.path.isfile(TFILE) is False # absence of stamped file
assert os.path.isfile(BASIS) # presence unstamped file
try:
os.remove("test.txt")
except OSError:
print("Running remove test, file 'test.txt' was not erased.")
sys.exit()
#+end_src