88
99import pytest
1010
11+ from openhexa .graphql import GetConnectionConnectionBySlug
1112from openhexa .sdk .workspaces .connection import (
1213 CustomConnection ,
1314 DHIS2Connection ,
@@ -318,10 +319,10 @@ def test_workspace_tmp_path(self, monkeypatch, workspace):
318319
319320 def test_workspace_get_connection_not_exist (self , workspace ):
320321 """Test get connection not found."""
321- data = { "connectionBySlug" : None }
322+ data = None
322323
323324 with mock .patch (
324- "openhexa.sdk.workspaces.current_workspace.graphql " ,
325+ "openhexa.sdk.workspaces.current_workspace.OpenHexaClient.get_connection " ,
325326 return_value = data ,
326327 ):
327328 with pytest .raises (ValueError ):
@@ -330,34 +331,33 @@ def test_workspace_get_connection_not_exist(self, workspace):
330331 def test_workspace_get_connection_case_insensitive (self , workspace ):
331332 """Test get connection."""
332333 data = {
333- "connectionBySlug" : {
334- "type" : "CUSTOM" ,
335- "fields" : [{"code" : "field_1" , "value" : "field_1_value" }],
336- }
334+ "__typename" : "CustomConnection" ,
335+ "type" : "CUSTOM" ,
336+ "fields" : [{"code" : "field_1" , "value" : "field_1_value" }],
337337 }
338+ mocked_data = GetConnectionConnectionBySlug (** data )
338339 with mock .patch (
339- "openhexa.sdk.workspaces.current_workspace.graphql " ,
340- return_value = data ,
340+ "openhexa.sdk.workspaces.current_workspace.OpenHexaClient.get_connection " ,
341+ return_value = mocked_data ,
341342 ):
342343 connection = workspace .get_connection ("RaNDom" )
343344 assert isinstance (connection , CustomConnection )
344345
345346 def test_workspace_get_connection (self , workspace ):
346347 """Test get connection."""
347348 data = {
348- "connectionBySlug" : {
349- "type" : "S3" ,
350- "fields" : [
351- {"code" : "bucket_name" , "value" : "bucket_name" },
352- {"code" : "access_key_id" , "value" : "access_key_id" },
353- {"code" : "access_key_secret" , "value" : "secret_access_key" },
354- ],
355- }
349+ "__typename" : "S3Connection" ,
350+ "type" : "S3" ,
351+ "fields" : [
352+ {"code" : "bucket_name" , "value" : "bucket_name" },
353+ {"code" : "access_key_id" , "value" : "access_key_id" },
354+ {"code" : "access_key_secret" , "value" : "secret_access_key" },
355+ ],
356356 }
357-
357+ mocked_data = GetConnectionConnectionBySlug ( ** data )
358358 with mock .patch (
359- "openhexa.sdk.workspaces.current_workspace.graphql " ,
360- return_value = data ,
359+ "openhexa.sdk.workspaces.current_workspace.OpenHexaClient.get_connection " ,
360+ return_value = mocked_data ,
361361 ):
362362 connection = workspace .get_connection ("s3-connection" )
363363 assert isinstance (connection , S3Connection )
0 commit comments