mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Dash encoding functions, tests and docs, refs #1439
This commit is contained in:
parent
7d24fd405f
commit
d1cb73180b
3 changed files with 51 additions and 0 deletions
|
|
@ -646,3 +646,19 @@ async def test_derive_named_parameters(sql, expected):
|
|||
db = ds.get_database("_memory")
|
||||
params = await utils.derive_named_parameters(db, sql)
|
||||
assert params == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"original,expected",
|
||||
(
|
||||
("abc", "abc"),
|
||||
("/foo/bar", "-/foo-/bar"),
|
||||
("/-/bar", "-/---/bar"),
|
||||
("-/db-/table---.csv-.csv", "---/db---/table-------.csv---.csv"),
|
||||
),
|
||||
)
|
||||
def test_dash_encoding(original, expected):
|
||||
actual = utils.dash_encode(original)
|
||||
assert actual == expected
|
||||
# And test round-trip
|
||||
assert original == utils.dash_decode(actual)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue