mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Doumentation and test for utils.parse_metadata(), closes #1405
This commit is contained in:
parent
eccfeb0871
commit
121e10c29c
2 changed files with 34 additions and 0 deletions
|
|
@ -610,3 +610,19 @@ async def test_initial_path_for_datasette(tmp_path_factory, dbs, expected_path):
|
|||
)
|
||||
path = await utils.initial_path_for_datasette(datasette)
|
||||
assert path == expected_path
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"content,expected",
|
||||
(
|
||||
("title: Hello", {"title": "Hello"}),
|
||||
('{"title": "Hello"}', {"title": "Hello"}),
|
||||
("{{ this }} is {{ bad }}", None),
|
||||
),
|
||||
)
|
||||
def test_parse_metadata(content, expected):
|
||||
if expected is None:
|
||||
with pytest.raises(utils.BadMetadataError):
|
||||
utils.parse_metadata(content)
|
||||
else:
|
||||
assert utils.parse_metadata(content) == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue