Skip to content

Commit

Permalink
updating tests for nested metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Apr 8, 2020
1 parent aec986b commit 4847350
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ exclude: >
\.vscode/settings\.json|
tests/commonmark/commonmark\.json|
.*\.xml|
tests/.*\.txt
tests/.*\.txt|
tests/test_parser.py|
tests/test_text_based.py
)$
repos:
Expand Down
21 changes: 19 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ def test_basic_run(sphinx_run, file_regression):
sphinx_run.build()
# print(sphinx_run.status())
assert sphinx_run.warnings() == ""
assert sphinx_run.app.env.metadata == {"basic_run": {"test_name": "notebook1"}}
assert sphinx_run.app.env.metadata == {
"basic_run": {
"test_name": "notebook1",
"kernelspec": '{"display_name": "Python 3", "language": "python", "name": "python3"}',
"language_info": '{"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1"}',
}
}
file_regression.check(sphinx_run.get_doctree().pformat(), extension=".xml")

filenames = {
Expand All @@ -23,7 +29,18 @@ def test_complex_outputs(sphinx_run, file_regression):
# print(sphinx_run.status())
assert sphinx_run.warnings() == ""
assert sphinx_run.app.env.metadata == {
"complex_outputs": {"celltoolbar": "Edit Metadata", "hide_input": "False"}
"complex_outputs": {
"celltoolbar": "Edit Metadata",
"hide_input": "False",
"ipub": '{"bibliography": "example.bib", "biboptions": ["super", "sort"], "bibstyle": "unsrtnat", "language": "portuges", "listcode": true, "listfigures": true, "listtables": true, "titlepage": {"author": "Authors Name", "email": "[email protected]", "institution": ["Institution1", "Institution2"], "logo": "logo_example.png", "subtitle": "Sub-Title", "supervisors": ["First Supervisor", "Second Supervisor"], "tagline": "A tagline for the report.", "title": "Main-Title"}, "toc": {"depth": 2}, "pandoc": {"use_numref": true, "at_notation": true}, "sphinx": {"bib_title": "My Bibliography"}}',
"jupytext": '{"metadata_filter": {"notebook": "ipub"}}',
"kernelspec": '{"display_name": "Python 3", "language": "python", "name": "python3"}',
"language_info": '{"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2"}',
"latex_envs": '{"LaTeX_envs_menu_present": true, "autocomplete": true, "bibliofile": "example.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": {"equation": "Ctrl-E", "itemize": "Ctrl-I"}, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": true}',
"nav_menu": "{}",
"toc": '{"colors": {"hover_highlight": "#DAA520", "navigate_num": "#000000", "navigate_text": "#333333", "running_highlight": "#FF0000", "selected_highlight": "#FFD700", "sidebar_border": "#EEEEEE", "wrapper_background": "#FFFFFF"}, "moveMenuLeft": true, "nav_menu": {"height": "161px", "width": "252px"}, "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 4, "toc_cell": false, "toc_section_display": "block", "toc_window_display": true, "widenNotebook": false}',
"varInspector": '{"cols": {"lenName": 16, "lenType": 16, "lenVar": 40}, "kernels_config": {"python": {"delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())"}, "r": {"delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) "}}, "types_to_exclude": ["module", "function", "builtin_function_or_method", "instance", "_Feature"], "window_display": false}',
}
}
file_regression.check(sphinx_run.get_doctree().pformat(), extension=".xml")

Expand Down
10 changes: 9 additions & 1 deletion tests/test_text_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ def test_basic_run(sphinx_run, file_regression, check_nbs):
sphinx_run.build()
# print(sphinx_run.status())
assert sphinx_run.warnings() == ""
assert sphinx_run.app.env.metadata == {"basic_unrun": {"author": "Chris"}}
assert sphinx_run.app.env.metadata == {
"basic_unrun": {
"jupytext": '{"text_representation": {"extension": ".md", "format_name": "myst", "format_version": "0.8", "jupytext_version": "1.4.1+dev"}}',
"kernelspec": '{"display_name": "Python 3", "language": "python", "name": "python3"}',
"author": "Chris",
"source_map": "[13, 19]",
"language_info": '{"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3"}',
}
}
file_regression.check(sphinx_run.get_nb(), check_fn=check_nbs, extension=".ipynb")
file_regression.check(sphinx_run.get_doctree().pformat(), extension=".xml")

0 comments on commit 4847350

Please sign in to comment.