From eba15fb5a8c8b155d1a33c1f3357fdfb29eb7041 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 23 Jun 2019 16:49:57 -0700 Subject: [PATCH] Renamed Request.from_path_with_query_string() to Request.fake() --- datasette/utils/asgi.py | 4 +--- tests/test_utils.py | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/datasette/utils/asgi.py b/datasette/utils/asgi.py index 08cb44aa..63034872 100644 --- a/datasette/utils/asgi.py +++ b/datasette/utils/asgi.py @@ -62,9 +62,7 @@ class Request: return {key: value[0] for key, value in self.args.items()} @classmethod - def from_path_with_query_string( - cls, path_with_query_string, method="GET", scheme="http" - ): + def fake(cls, path_with_query_string, method="GET", scheme="http"): "Useful for constructing Request objects for tests" path, _, query_string = path_with_query_string.partition("?") scope = { diff --git a/tests/test_utils.py b/tests/test_utils.py index cbf9eba7..e9e722b8 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -53,7 +53,7 @@ def test_urlsafe_components(path, expected): ], ) def test_path_with_added_args(path, added_args, expected): - request = Request.from_path_with_query_string(path) + request = Request.fake(path) actual = utils.path_with_added_args(request, added_args) assert expected == actual @@ -67,11 +67,11 @@ def test_path_with_added_args(path, added_args, expected): ], ) def test_path_with_removed_args(path, args, expected): - request = Request.from_path_with_query_string(path) + request = Request.fake(path) actual = utils.path_with_removed_args(request, args) assert expected == actual # Run the test again but this time use the path= argument - request = Request.from_path_with_query_string("/") + request = Request.fake("/") actual = utils.path_with_removed_args(request, args, path=path) assert expected == actual @@ -84,7 +84,7 @@ def test_path_with_removed_args(path, args, expected): ], ) def test_path_with_replaced_args(path, args, expected): - request = Request.from_path_with_query_string(path) + request = Request.fake(path) actual = utils.path_with_replaced_args(request, args) assert expected == actual @@ -363,7 +363,7 @@ def test_table_columns(): ], ) def test_path_with_format(path, format, extra_qs, expected): - request = Request.from_path_with_query_string(path) + request = Request.fake(path) actual = utils.path_with_format(request, format, extra_qs) assert expected == actual