def test_getLink_found(inv_reader_nolog: sphinx.SphinxInventory) -> None: """ Return the link from internal state. """ inv_reader_nolog._links['some.name'] = ('http://base.tld', 'some/url.php') assert 'http://base.tld/some/url.php' == inv_reader_nolog.getLink( 'some.name')
def test_getLink_self_anchor(inv_reader_nolog: sphinx.SphinxInventory) -> None: """ Return the link with anchor as target name when link end with $. """ inv_reader_nolog._links['some.name'] = ('http://base.tld', 'some/url.php#$') assert 'http://base.tld/some/url.php#some.name' == inv_reader_nolog.getLink( 'some.name')
def test_update_functional(inv_reader_nolog: sphinx.SphinxInventory) -> None: """ Functional test for updating from an empty inventory. """ payload = (b'some.module1 py:module -1 module1.html -\n' b'other.module2 py:module 0 module2.html Other description\n') # Patch URL loader to avoid hitting the system. content = b"""# Sphinx inventory version 2 # Project: some-name # Version: 2.0 # The rest of this file is compressed with zlib. """ + zlib.compress(payload) url = 'http://some.url/api/objects.inv' inv_reader_nolog.update({url: content}, url) assert 'http://some.url/api/module1.html' == inv_reader_nolog.getLink( 'some.module1') assert 'http://some.url/api/module2.html' == inv_reader_nolog.getLink( 'other.module2')
def test_getLink_not_found(inv_reader_nolog: sphinx.SphinxInventory) -> None: """ Return None if link does not exists. """ assert None is inv_reader_nolog.getLink('no.such.name')