Skip to content

Commit

Permalink
test: test docs extensions in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Nov 19, 2018
1 parent 7e689d1 commit c2dadfb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -22,7 +22,7 @@ jobs:
# stage 1, all following runs in parallel:
- stage: "quality checks & tests"
env: "JOB=quality_checks"
script: "npm run lint && npm run docs:lint"
script: "npm run lint && npm run docs:lint && npm run docs:test-extensions"
- env: "JOB=docs_build_dry_run" # why dry run? because production build happens directly on ReadTheDocs infrastructure
script: "npm run docs:build"
- env: "JOB=node6"
Expand Down
29 changes: 22 additions & 7 deletions docs/extensions/ghissue.py
@@ -1,4 +1,5 @@
import re
import unittest

from docutils import nodes
from sphinx.errors import SphinxError
Expand Down Expand Up @@ -30,11 +31,25 @@ def setup(app):
return {'version': '1.0', 'parallel_read_safe': True}


# Primitive tests. Run this as follows and watch out for assertion errors:
#
# $ python docs/extensions/ghissue.py
#
class Tests(unittest.TestCase):
def test_owner_repo_issueno(self):
self.assertEqual(
parse_text('refractproject/minim#83'),
'https://github.com/refractproject/minim/issues/83'
)

def test_repo_issueno(self):
self.assertEqual(
parse_text('dredd-transactions#163'),
'https://github.com/apiaryio/dredd-transactions/issues/163'
)

def test_issueno(self):
self.assertEqual(
parse_text('#1119'),
'https://github.com/apiaryio/dredd/issues/1119'
)


if __name__ == '__main__':
assert parse_text('refractproject/minim#83') == 'https://github.com/refractproject/minim/issues/83'
assert parse_text('dredd-transactions#163') == 'https://github.com/apiaryio/dredd-transactions/issues/163'
assert parse_text('#1119') == 'https://github.com/apiaryio/dredd/issues/1119'
unittest.main()
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -14,6 +14,7 @@
"build:watch": "babel ./src --out-dir ./lib --copy-files --watch",
"coveralls": "./scripts/coveralls.sh",
"docs:lint": "doc8 ./docs && sphinx-build -nW -b linkcheck ./docs ./docs/_build",
"docs:test-extensions": "python -m unittest docs/extensions/*.py --verbose",
"docs:build": "sphinx-build -nW -b html ./docs ./docs/_build",
"docs:serve": "sphinx-autobuild ./docs ./docs/_build",
"lint": "conventional-changelog-lint --from=master && eslint .",
Expand Down

0 comments on commit c2dadfb

Please sign in to comment.