Changeset - cf2d825a08db
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-08-30 13:18:41
brettcsmith@brettcsmith.org
tests: Reorganize extract_odf_links tests for new feature.
1 file changed with 15 insertions and 6 deletions:
0 comments (0 inline, 0 general)
tests/test_extract_odf_links.py
Show inline comments
...
 
@@ -18,18 +18,26 @@ import io
 

	
 
import pytest
 

	
 
from pathlib import Path
 

	
 
from . import testutil
 

	
 
from conservancy_beancount.tools import extract_odf_links
 

	
 
SRC_PATH = testutil.test_path('repository/LinksReport.ods')
 

	
 
EXPECTED_FILE_LINKS = {
 
    '/repository/Projects/project-data.yml',
 
    str(testutil.test_path('repository/Projects/project-data.yml')),
 
    str(testutil.test_path('repository/Projects/Bad Link.txt')),
 
INCLUDED_FILE_LINKS = {
 
    Path('/repository/Projects/project-data.yml'),
 
    Path('Projects/project-data.yml'),
 
    Path('Projects/Bad Link.txt'),
 
}
 

	
 
def expected_links(rel_path):
 
    return frozenset(
 
        str(path if path.is_absolute() else rel_path / path)
 
        for path in INCLUDED_FILE_LINKS
 
    )
 

	
 
@pytest.mark.parametrize('arglist,sep', [
 
    (['-0'], '\0'),
 
    (['-d', '\\v'], '\v'),
...
 
@@ -45,8 +53,9 @@ def test_extract_file_links(arglist, sep, caplog):
 
    actual = stdout.getvalue().split(sep)
 
    if actual and not actual[-1]:
 
        actual.pop()
 
    assert len(actual) == len(EXPECTED_FILE_LINKS)
 
    assert set(actual) == EXPECTED_FILE_LINKS
 
    expected = expected_links(SRC_PATH.parent)
 
    assert len(actual) == len(expected)
 
    assert set(actual) == expected
 
    assert caplog.records
 
    assert any(
 
        log.levelname == 'WARNING'
0 comments (0 inline, 0 general)