1"""
2    test_metadata
3    ~~~~~~~~~~~~~
4
5    Test our handling of metadata in files with bibliographic metadata.
6
7    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
8    :license: BSD, see LICENSE for details.
9"""
10
11# adapted from an example of bibliographic metadata at
12# http://docutils.sourceforge.net/docs/user/rst/demo.txt
13
14import pytest
15
16
17@pytest.mark.sphinx('dummy', testroot='metadata')
18def test_docinfo(app, status, warning):
19    """
20    Inspect the 'docinfo' metadata stored in the first node of the document.
21    Note this doesn't give us access to data stored in subsequence blocks
22    that might be considered document metadata, such as 'abstract' or
23    'dedication' blocks, or the 'meta' role. Doing otherwise is probably more
24    messing with the internals of sphinx than this rare use case merits.
25    """
26    app.build()
27    expecteddocinfo = {
28        'author': 'David Goodger',
29        'authors': ['Me', 'Myself', 'I'],
30        'address': '123 Example Street\nExample, EX  Canada\nA1B 2C3',
31        'field name': 'This is a generic bibliographic field.',
32        'field name 2': ('Generic bibliographic fields may contain multiple '
33                         'body elements.\n\nLike this.'),
34        'status': 'This is a “work in progress”',
35        'version': '1',
36        'copyright': ('This document has been placed in the public domain. '
37                      'You\nmay do with it as you wish. You may copy, modify,'
38                      '\nredistribute, reattribute, sell, buy, rent, lease,\n'
39                      'destroy, or improve it, quote it at length, excerpt,\n'
40                      'incorporate, collate, fold, staple, or mutilate it, or '
41                      'do\nanything else to it that your or anyone else’s '
42                      'heart\ndesires.'),
43        'contact': 'goodger@python.org',
44        'date': '2006-05-21',
45        'organization': 'humankind',
46        'revision': '4564',
47        'tocdepth': 1,
48        'orphan': '',
49        'nocomments': '',
50    }
51    assert app.env.metadata['index'] == expecteddocinfo
52