docs: docs: update documentation, second set of tests

Documentation about the second set of tests (prepend a string to
the original file name of a file) was updated.

Signed-off-by: Norwid Behrnd <nbehrnd@yahoo.com>
This commit is contained in:
Norwid Behrnd 2024-11-03 20:04:24 +01:00
parent 3e9786f62c
commit a9498889bc
2 changed files with 11 additions and 38 deletions

View file

@ -108,6 +108,10 @@ def test_append(arg1, arg2, arg3):
os.remove(new_filename)
assert os.path.isfile(new_filename) is False
# The following section is about tests to prepend a user defined string and
# an adjustable separator to the original file name of the file submitted. By
# permutation of the parameter's levels, this defines 240 tests.
arg1_values = [
"test.txt", "2021-12-31_test.txt", "2021-12-31T18.48.22_test.txt"
]

View file

@ -292,11 +292,15 @@ def test_append(arg1, arg2, arg3):
*** appendfilename, prepend position
Departing with file =test.txt=, appendfile's addition of =example=
should yield =example test.txt=. Testing so far skips the
addition of string containing spaces, as well as the implicit
spacing.
should yield =example test.txt=. The 240 tests equally consider the
separator between the string added, and the original file name.
#+begin_src python :tangle test_appendfilename.py
# The following section is about tests to prepend a user defined string and
# an adjustable separator to the original file name of the file submitted. By
# permutation of the parameter's levels, this defines 240 tests.
arg1_values = [
"test.txt", "2021-12-31_test.txt", "2021-12-31T18.48.22_test.txt"
]
@ -360,41 +364,6 @@ def test_prepend(arg1, arg2, arg3, arg4):
assert os.path.isfile(new_filename) is False
#+end_src
@pytest.mark.prepend
@pytest.mark.parametrize("arg1", ["test.txt", "2021-12-31_test.txt",
"2021-12-31T18.48.22_test.txt",
"20211231_test.txt", "2012-12_test.txt",
"211231_test.txt"])
@pytest.mark.parametrize("arg2", ["-t book", "-t book_shelf",
"--text book", "--text book_shelf"])
@pytest.mark.parametrize("arg3", [" ", "!", "@", "#", "$", "%", "*", "_", "+",
"=", "-"])
@pytest.mark.parametrize("arg4", ["-p", "--prepend"])
def test_pattern_s2(arg1, arg2, arg3, arg4):
"""Check addition just ahead the file extension.
arg1 the test files to process
arg2 the text string to be added
arg3 the explicitly defined text separator (except [a-zA-Z])
arg4 use either of two forms of the prepend flag."""
# extract the newly added text information:
text_elements = arg2.split(" ")[1:]
text = str(" ".join(text_elements))
with open(arg1, mode="w") as newfile:
newfile.write("This is a test file for test_appendfilename.")
test = getoutput(f"python3 {PROGRAM} {arg1} {arg2} --separator={arg3} {arg4}")
new_filename = "".join([text, arg3, arg1])
assert os.path.isfile(new_filename)
os.remove(new_filename)
assert os.path.isfile(new_filename) is False
#+end_src
*** appendfilename, smart prepend position
If a file has a leading time stamp like =YYYY-MM-DD_=, or