2016-10-03 18:13:23 -07:00
|
|
|
"""
|
|
|
|
Tests for the ``releases.util`` module.
|
|
|
|
|
|
|
|
These are in the integration suite because they deal with on-disk files.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2016-10-06 15:07:34 -07:00
|
|
|
from docutils.nodes import document
|
|
|
|
from spec import Spec, ok_, eq_
|
2016-10-06 15:14:59 -07:00
|
|
|
from sphinx.application import Sphinx
|
2016-10-03 18:13:23 -07:00
|
|
|
|
2016-10-06 15:07:34 -07:00
|
|
|
from releases.models import Release, Issue
|
2016-10-03 18:13:23 -07:00
|
|
|
from releases.util import get_doctree
|
|
|
|
|
|
|
|
support = os.path.join(os.path.dirname(__file__), '_support')
|
|
|
|
|
|
|
|
|
|
|
|
class get_doctree_(Spec):
|
2016-10-06 15:14:59 -07:00
|
|
|
def obtains_app_and_doctree_from_filepath(self):
|
2016-10-03 18:13:23 -07:00
|
|
|
vanilla = os.path.join(support, 'vanilla', 'changelog.rst')
|
2016-10-06 15:14:59 -07:00
|
|
|
app, doctree = get_doctree(vanilla)
|
|
|
|
# Expect doctree & app
|
2016-10-06 15:07:34 -07:00
|
|
|
ok_(doctree)
|
2016-10-06 15:14:59 -07:00
|
|
|
ok_(app)
|
2016-10-06 15:07:34 -07:00
|
|
|
ok_(isinstance(doctree, document))
|
2016-10-06 15:14:59 -07:00
|
|
|
ok_(isinstance(app, Sphinx))
|
2016-10-06 15:07:34 -07:00
|
|
|
# Sanity checks of internal nodes, which should be Releases objects
|
|
|
|
entries = doctree[0][2]
|
|
|
|
ok_(isinstance(entries[0][0][0], Release))
|
|
|
|
bug = entries[1][0][0]
|
|
|
|
ok_(isinstance(bug, Issue))
|
|
|
|
eq_(bug.type, 'bug')
|
|
|
|
eq_(bug.number, '1')
|