test_files_corpus_bare_term.py

tests/test_files_corpus_bare_term.py

Seven indexed source files, and the corpus that lists files said there were none.

test_a_bare_term_finds_the_files_containing_it

None test_files_corpus_bare_term.test_a_bare_term_finds_the_files_containing_it(Path files_db)

A bare term must list the files whose paths contain it.

tests/test_files_corpus_bare_term.py:85

Show on the map →

Called by none

Calls all, list_files

Checks

  • assert len(names) == 3, f"a bare term found {len(names)} of 3 llama files: {names}"
  • assert all("llama" in n for n in names), names

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_a_bare_term_finds_the_files_containing_it → list_files
REQ-DDB-QUERY-003measuredtest_a_bare_term_finds_the_files_containing_it → list_files → table_exists
REQ-DDB-WIKI-054inferredtest_a_bare_term_finds_the_files_containing_it → all
Source · 14 lines
def test_a_bare_term_finds_the_files_containing_it(files_db: Path) -> None:
    """THE REGRESSION, NAMED. `llama` is not a path and never matches as a glob, so this returned
    nothing while three matching files sat in the table.

    @brief A bare term matches by substring.
    @return None.
    @version 1
    """
    names = [f.path for f in list_files(files_db, "llama")]

    assert len(names) == 3, f"a bare term found {len(names)} of 3 llama files: {names}"
    assert all("llama" in n for n in names), names

Activity · 3 steps
lines 93–93names = [f.path for f in list_files(files_db, "llama")]lines 95–95assert len(names) == 3, f"a bare term found {len(names)} of 3 llama files: {names}"lines 96–96assert all("llama" in n for n in names), names

test_a_term_that_matches_nothing_still_returns_nothing

None test_files_corpus_bare_term.test_a_term_that_matches_nothing_still_returns_nothing(Path files_db)

A term matching nothing must still return nothing.

tests/test_files_corpus_bare_term.py:131

Show on the map →

Called by none

Calls list_files

Checks

  • assert list_files(files_db, "no_such_thing_anywhere") == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_a_term_that_matches_nothing_still_returns_nothing → list_files
REQ-DDB-QUERY-003measuredtest_a_term_that_matches_nothing_still_returns_nothing → list_files → table_exists
Source · 9 lines
def test_a_term_that_matches_nothing_still_returns_nothing(files_db: Path) -> None:
    """THE PERMISSIVE FAILURE. A fix that returned every file when the term missed would make the
    corpus useless and would read as success against the test above.

    @brief A genuine miss is still a miss.
    @return None.
    @version 1
    """
    assert list_files(files_db, "no_such_thing_anywhere") == []

1 more lines, not shown

Activity · 1 steps
lines 139–139assert list_files(files_db, "no_such_thing_anywhere") == []

test_an_explicit_glob_is_unchanged

None test_files_corpus_bare_term.test_an_explicit_glob_is_unchanged(Path files_db, str glob, int expected)

An explicit glob must keep working exactly as before.

tests/test_files_corpus_bare_term.py:110

Show on the map →

Called by none

Calls list_files

Checks

  • assert len(list_files(files_db, glob)) == expected, (f"glob {glob!r} no longer matches {expected} file(s)" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_an_explicit_glob_is_unchanged → list_files
REQ-DDB-QUERY-003measuredtest_an_explicit_glob_is_unchanged → list_files → table_exists
Source · 16 lines
def test_an_explicit_glob_is_unchanged(files_db: Path, glob: str, expected: int) -> None:
    """THE HALF THAT MUST NOT MOVE. Globbing is the documented behaviour and other callers depend
    on it; a fix that turned every glob into a substring search would trade one wrong answer for
    a broader one. A term containing `*`, `?` or `[` is taken at its word.

    @brief Globs are untouched.
    @param glob The glob.
    @param expected Expected match count.
    @return None.
    @version 1
    """
    assert len(list_files(files_db, glob)) == expected, (
        f"glob {glob!r} no longer matches {expected} file(s)"
    )

Activity · 1 steps
lines 121–123assert len(list_files(files_db, glob)) == expected, ( f"glob {glob!r} no longer matches {expected} file(s)" )