Skip to content

Commit

Permalink
re-use make msg
Browse files Browse the repository at this point in the history
  • Loading branch information
dfalbel committed Apr 9, 2024
1 parent 1a36350 commit 1224bc5
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def get_sqlite_connections():
return [get_sqlalchemy_sqlite_connection(), get_sqlite3_sqlite_connection()]


def _make_msg(method, params, comm_id):
return json_rpc_request(method=method, params=params, comm_id=comm_id)


@pytest.fixture(scope="function")
def connections_comm(
connections_service: ConnectionsService, con
Expand Down Expand Up @@ -70,7 +74,7 @@ def test_contains_data(
):
_, comm = connections_comm

msg = self._make_msg(params={"path": path}, method="contains_data", comm_id=comm.comm_id)
msg = _make_msg(params={"path": path}, method="contains_data", comm_id=comm.comm_id)
comm.handle_msg(msg)

result = comm.messages[0]["data"]["result"]
Expand All @@ -86,7 +90,7 @@ def test_contains_data(
def test_get_icon(self, connections_comm: Tuple[ConnectionsService, DummyComm], path, expected):
_, comm = connections_comm

msg = self._make_msg(params={"path": path}, method="get_icon", comm_id=comm.comm_id)
msg = _make_msg(params={"path": path}, method="get_icon", comm_id=comm.comm_id)
comm.handle_msg(msg)
result = comm.messages[0]["data"]["result"]
assert result == expected
Expand All @@ -103,7 +107,7 @@ def test_list_objects(
):
_, comm = connections_comm

msg = self._make_msg(params={"path": path}, method="list_objects", comm_id=comm.comm_id)
msg = _make_msg(params={"path": path}, method="list_objects", comm_id=comm.comm_id)

comm.handle_msg(msg)
result = comm.messages[0]["data"]["result"]
Expand All @@ -113,7 +117,7 @@ def test_list_objects(
def test_list_fields(self, connections_comm: Tuple[ConnectionsService, DummyComm]):
_, comm = connections_comm

msg = self._make_msg(
msg = _make_msg(
params={
"path": [{"kind": "schema", "name": "main"}, {"kind": "table", "name": "movie"}]
},
Expand All @@ -130,7 +134,7 @@ def test_list_fields(self, connections_comm: Tuple[ConnectionsService, DummyComm
def test_preview_object(self, connections_comm: Tuple[ConnectionsService, DummyComm]):
service, comm = connections_comm

msg = self._make_msg(
msg = _make_msg(
params={
"path": [{"kind": "schema", "name": "main"}, {"kind": "table", "name": "movie"}]
},
Expand All @@ -143,9 +147,6 @@ def test_preview_object(self, connections_comm: Tuple[ConnectionsService, DummyC
result = comm.messages[0]["data"]["result"]
assert result is None

def _make_msg(self, method, params, comm_id):
return json_rpc_request(method=method, params=params, comm_id=comm_id)


class TestVariablePaneIntegration:

Expand Down Expand Up @@ -213,8 +214,8 @@ def _delete_variables(self, shell: PositronShell, variables_comm: DummyComm, nam
variables_comm.messages.clear()

def _view_in_connections_pane(self, variables_comm: DummyComm, path):
path = [encode_access_key(p) for p in path]
msg = json_rpc_request("view", {"path": path}, comm_id="dummy_comm_id")
paths = [encode_access_key(p) for p in path]
msg = _make_msg("view", {"path": paths}, comm_id="dummy_comm_id")
variables_comm.handle_msg(msg)
assert variables_comm.messages == [json_rpc_response({})]
variables_comm.messages.clear()
Expand Down

0 comments on commit 1224bc5

Please sign in to comment.