mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
dea9f94742
commit
ec758527b6
4 changed files with 66 additions and 3 deletions
|
|
@ -15,6 +15,10 @@ import time
|
|||
from urllib.parse import unquote
|
||||
|
||||
|
||||
# This temp file is used by one of the plugin config tests
|
||||
TEMP_PLUGIN_SECRET_FILE = os.path.join(tempfile.gettempdir(), "plugin-secret")
|
||||
|
||||
|
||||
class TestResponse:
|
||||
def __init__(self, status, headers, body):
|
||||
self.status = status
|
||||
|
|
@ -246,7 +250,11 @@ METADATA = {
|
|||
"source_url": "https://github.com/simonw/datasette/blob/master/tests/fixtures.py",
|
||||
"about": "About Datasette",
|
||||
"about_url": "https://github.com/simonw/datasette",
|
||||
"plugins": {"name-of-plugin": {"depth": "root"}},
|
||||
"plugins": {
|
||||
"name-of-plugin": {"depth": "root"},
|
||||
"env-plugin": {"foo": {"$env": "FOO_ENV"}},
|
||||
"file-plugin": {"foo": {"$file": TEMP_PLUGIN_SECRET_FILE}},
|
||||
},
|
||||
"databases": {
|
||||
"fixtures": {
|
||||
"description": "Test tables description",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from bs4 import BeautifulSoup as Soup
|
||||
from .fixtures import app_client # noqa
|
||||
from .fixtures import app_client, make_app_client, TEMP_PLUGIN_SECRET_FILE # noqa
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import pytest
|
||||
import urllib
|
||||
|
|
@ -125,6 +126,18 @@ def test_plugin_config(app_client):
|
|||
assert None is app_client.ds.plugin_config("unknown-plugin")
|
||||
|
||||
|
||||
def test_plugin_config_env(app_client):
|
||||
os.environ["FOO_ENV"] = "FROM_ENVIRONMENT"
|
||||
assert {"foo": "FROM_ENVIRONMENT"} == app_client.ds.plugin_config("env-plugin")
|
||||
del os.environ["FOO_ENV"]
|
||||
|
||||
|
||||
def test_plugin_config_file(app_client):
|
||||
open(TEMP_PLUGIN_SECRET_FILE, "w").write("FROM_FILE")
|
||||
assert {"foo": "FROM_FILE"} == app_client.ds.plugin_config("file-plugin")
|
||||
os.remove(TEMP_PLUGIN_SECRET_FILE)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"path,expected_extra_body_script",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue