mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Added plugin_config() method
This commit is contained in:
parent
1905c03364
commit
0a14a4846b
6 changed files with 114 additions and 6 deletions
|
|
@ -129,9 +129,19 @@ METADATA = {
|
|||
'license_url': 'https://github.com/simonw/datasette/blob/master/LICENSE',
|
||||
'source': 'tests/fixtures.py',
|
||||
'source_url': 'https://github.com/simonw/datasette/blob/master/tests/fixtures.py',
|
||||
"plugins": {
|
||||
"name-of-plugin": {
|
||||
"depth": "root"
|
||||
}
|
||||
},
|
||||
'databases': {
|
||||
'fixtures': {
|
||||
'description': 'Test tables description',
|
||||
"plugins": {
|
||||
"name-of-plugin": {
|
||||
"depth": "database"
|
||||
}
|
||||
},
|
||||
'tables': {
|
||||
'simple_primary_key': {
|
||||
'description_html': 'Simple <em>primary</em> key',
|
||||
|
|
@ -143,7 +153,12 @@ METADATA = {
|
|||
'sortable_with_nulls',
|
||||
'sortable_with_nulls_2',
|
||||
'text',
|
||||
]
|
||||
],
|
||||
"plugins": {
|
||||
"name-of-plugin": {
|
||||
"depth": "table"
|
||||
}
|
||||
}
|
||||
},
|
||||
'no_primary_key': {
|
||||
'sortable_columns': [],
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ label_re = re.compile(r'\.\. _([^\s:]+):')
|
|||
|
||||
def get_headings(filename, underline="-"):
|
||||
content = (docs_path / filename).open().read()
|
||||
heading_re = re.compile(r'(\S+)\n\{}+\n'.format(underline))
|
||||
return set(heading_re.findall(content))
|
||||
heading_re = re.compile(r'(\w+)(\([^)]*\))?\n\{}+\n'.format(underline))
|
||||
return set(h[0] for h in heading_re.findall(content))
|
||||
|
||||
|
||||
def get_labels(filename):
|
||||
|
|
|
|||
|
|
@ -85,3 +85,20 @@ def test_plugins_render_cell(app_client):
|
|||
assert a is not None, str(a)
|
||||
assert a.attrs["href"] == "http://example.com/"
|
||||
assert a.text == "Example"
|
||||
|
||||
|
||||
def test_plugin_config(app_client):
|
||||
assert {"depth": "table"} == app_client.ds.plugin_config(
|
||||
"name-of-plugin", database="fixtures", table="sortable"
|
||||
)
|
||||
assert {"depth": "database"} == app_client.ds.plugin_config(
|
||||
"name-of-plugin", database="fixtures", table="unknown_table"
|
||||
)
|
||||
assert {"depth": "database"} == app_client.ds.plugin_config(
|
||||
"name-of-plugin", database="fixtures"
|
||||
)
|
||||
assert {"depth": "root"} == app_client.ds.plugin_config(
|
||||
"name-of-plugin", database="unknown_database"
|
||||
)
|
||||
assert {"depth": "root"} == app_client.ds.plugin_config("name-of-plugin")
|
||||
assert None is app_client.ds.plugin_config("unknown-plugin")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue