Beispiel #1
0
def test_parse_sphinx_docopts():
    data = '''
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2.0.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    '''
    assert sg.parse_sphinx_docopts(data) == {
        'URL_ROOT': './',
        'VERSION': '2.0.2',
        'COLLAPSE_INDEX': False,
        'FILE_SUFFIX': '.html',
        'HAS_SOURCE': True,
        'SOURCELINK_SUFFIX': '.txt'
    }

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('empty input')

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('DOCUMENTATION_OPTIONS = ')

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('DOCUMENTATION_OPTIONS = {')
def test_parse_sphinx_docopts():
    data = '''
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2.0.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    '''
    assert sg.parse_sphinx_docopts(data) == {
        'URL_ROOT': './',
        'VERSION': '2.0.2',
        'COLLAPSE_INDEX': False,
        'FILE_SUFFIX': '.html',
        'HAS_SOURCE': True,
        'SOURCELINK_SUFFIX': '.txt'
    }

    data_sphinx_175 = '''
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT: document.getElementById("documentation_options")\
                  .getAttribute('data-url_root'),
        VERSION:     '2.0.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    '''
    assert sg.parse_sphinx_docopts(data_sphinx_175) == {
        'VERSION': '2.0.2',
        'COLLAPSE_INDEX': False,
        'FILE_SUFFIX': '.html',
        'HAS_SOURCE': True,
        'SOURCELINK_SUFFIX': '.txt'
    }

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('empty input')

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('DOCUMENTATION_OPTIONS = ')

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('DOCUMENTATION_OPTIONS = {')
def test_parse_sphinx_docopts():
    data = '''
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2.0.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    '''
    assert sg.parse_sphinx_docopts(data) == {
        'URL_ROOT': './',
        'VERSION': '2.0.2',
        'COLLAPSE_INDEX': False,
        'FILE_SUFFIX': '.html',
        'HAS_SOURCE': True,
        'SOURCELINK_SUFFIX': '.txt'
    }

    data_sphinx_175 = '''
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT: document.getElementById("documentation_options")\
                  .getAttribute('data-url_root'),
        VERSION:     '2.0.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    '''
    assert sg.parse_sphinx_docopts(data_sphinx_175) == {
        'VERSION': '2.0.2',
        'COLLAPSE_INDEX': False,
        'FILE_SUFFIX': '.html',
        'HAS_SOURCE': True,
        'SOURCELINK_SUFFIX': '.txt'
    }

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('empty input')

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('DOCUMENTATION_OPTIONS = ')

    with pytest.raises(ValueError):
        sg.parse_sphinx_docopts('DOCUMENTATION_OPTIONS = {')