Skip to content

Commit

Permalink
Merge pull request #3597 from mathesar-foundation/rpc_method_list_ref…
Browse files Browse the repository at this point in the history
…actor

Refactor list of RPC methods to test
  • Loading branch information
mathemancer authored May 20, 2024
2 parents dc399ba + cd0ec73 commit 135032f
Showing 1 changed file with 18 additions and 30 deletions.
48 changes: 18 additions & 30 deletions mathesar/tests/rpc/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@
from mathesar.rpc import connections


exposed_functions = [
"columns.list",
"connections.add_from_known_connection",
"connections.add_from_scratch",
METHODS = [
(
columns.list_,
"columns.list",
[user_is_authenticated]
),
(
connections.add_from_known_connection,
"connections.add_from_known_connection",
[user_is_superuser]
),
(
connections.add_from_scratch,
"connections.add_from_scratch",
[user_is_superuser]
)
]


Expand All @@ -31,34 +43,10 @@ def test_rpc_endpoint_expected_methods(live_server, admin_client):
content_type="application/json"
).json()["result"]
mathesar_methods = [m for m in all_methods if not m.startswith("system.")]
expect_methods = [
"columns.list",
"connections.add_from_known_connection",
"connections.add_from_scratch",
]
assert sorted(mathesar_methods) == expect_methods
assert sorted(mathesar_methods) == sorted(m[1] for m in METHODS)


@pytest.mark.parametrize(
"func,exposed_name,auth_pred_params",
[
(
columns.list_,
"columns.list",
[user_is_authenticated]
),
(
connections.add_from_known_connection,
"connections.add_from_known_connection",
[user_is_superuser]
),
(
connections.add_from_scratch,
"connections.add_from_scratch",
[user_is_superuser]
)
]
)
@pytest.mark.parametrize("func,exposed_name,auth_pred_params", METHODS)
def test_correctly_exposed(func, exposed_name, auth_pred_params):
"""Tests to make sure every RPC function is correctly wired up."""
# Make sure we didn't typo the function names for the endpoint.
Expand Down

0 comments on commit 135032f

Please sign in to comment.