@@ -211,37 +211,40 @@ def test_set_connection_not_implemented(self):
211211
212212 @patch ("builtins.open" , new_callable = mock_open , read_data = "" )
213213 def test_get_connection_creds_success (self , mock_open ):
214- profile_dict = {
214+ profiles_dict = {
215215 "a_profile" : {
216216 "outputs" : {
217217 "a_target" : {"type" : "TYPE1" , "credential_1" : "credential_1" , "credential_2" : "credential_2" }
218218 },
219219 "target" : "a_target" ,
220220 }
221221 }
222- expected_credentials = profile_dict ["a_profile" ]["outputs" ]["a_target" ]
222+ profile = profiles_dict ["a_profile" ]
223+ expected_credentials = profiles_dict ["a_profile" ]["outputs" ]["a_target" ]
223224 mock_self = Mock ()
224225 mock_self .profiles_dir = ""
225226 mock_self .project_dict = {"profile" : "a_profile" }
226- mock_self .yaml .safe_load .return_value = profile_dict
227- mock_self .ProfileRenderer ().render_data .return_value = expected_credentials
227+ mock_self .yaml .safe_load .return_value = profiles_dict
228+ mock_self .ProfileRenderer ().render_data .return_value = profile
228229 credentials , conn_type = DbtParser ._get_connection_creds (mock_self )
229230 self .assertEqual (credentials , expected_credentials )
230231 self .assertEqual (conn_type , "type1" )
231232
232233 @patch ("builtins.open" , new_callable = mock_open , read_data = "" )
233234 def test_get_connection_no_matching_profile (self , mock_open ):
234- profile_dict = {"a_profile" : {}}
235+ profiles_dict = {"a_profile" : {}}
235236 mock_self = Mock ()
236237 mock_self .profiles_dir = ""
237238 mock_self .project_dict = {"profile" : "wrong_profile" }
238- mock_self .yaml .safe_load .return_value = profile_dict
239+ mock_self .yaml .safe_load .return_value = profiles_dict
240+ profile = profiles_dict ["a_profile" ]
241+ mock_self .ProfileRenderer ().render_data .return_value = profile
239242 with self .assertRaises (ValueError ):
240243 _ , _ = DbtParser ._get_connection_creds (mock_self )
241244
242245 @patch ("builtins.open" , new_callable = mock_open , read_data = "" )
243246 def test_get_connection_no_target (self , mock_open ):
244- profile_dict = {
247+ profiles_dict = {
245248 "a_profile" : {
246249 "outputs" : {
247250 "a_target" : {"type" : "TYPE1" , "credential_1" : "credential_1" , "credential_2" : "credential_2" }
@@ -250,8 +253,10 @@ def test_get_connection_no_target(self, mock_open):
250253 }
251254 mock_self = Mock ()
252255 mock_self .profiles_dir = ""
256+ profile = profiles_dict ["a_profile" ]
257+ mock_self .ProfileRenderer ().render_data .return_value = profile
253258 mock_self .project_dict = {"profile" : "a_profile" }
254- mock_self .yaml .safe_load .return_value = profile_dict
259+ mock_self .yaml .safe_load .return_value = profiles_dict
255260 with self .assertRaises (ValueError ):
256261 _ , _ = DbtParser ._get_connection_creds (mock_self )
257262
@@ -262,24 +267,19 @@ def test_get_connection_no_target(self, mock_open):
262267
263268 @patch ("builtins.open" , new_callable = mock_open , read_data = "" )
264269 def test_get_connection_no_outputs (self , mock_open ):
265- profile_dict = {"a_profile" : {"target" : "a_target" }}
270+ profiles_dict = {"a_profile" : {"target" : "a_target" }}
266271 mock_self = Mock ()
267272 mock_self .profiles_dir = ""
268273 mock_self .project_dict = {"profile" : "a_profile" }
269- mock_self .yaml .safe_load .return_value = profile_dict
274+ profile = profiles_dict ["a_profile" ]
275+ mock_self .ProfileRenderer ().render_data .return_value = profile
276+ mock_self .yaml .safe_load .return_value = profiles_dict
270277 with self .assertRaises (ValueError ):
271278 _ , _ = DbtParser ._get_connection_creds (mock_self )
272279
273- profile_yaml_no_credentials = """
274- a_profile:
275- outputs:
276- a_target:
277- target: a_target
278- """
279-
280280 @patch ("builtins.open" , new_callable = mock_open , read_data = "" )
281281 def test_get_connection_no_credentials (self , mock_open ):
282- profile_dict = {
282+ profiles_dict = {
283283 "a_profile" : {
284284 "outputs" : {"a_target" : {}},
285285 "target" : "a_target" ,
@@ -288,13 +288,15 @@ def test_get_connection_no_credentials(self, mock_open):
288288 mock_self = Mock ()
289289 mock_self .profiles_dir = ""
290290 mock_self .project_dict = {"profile" : "a_profile" }
291- mock_self .yaml .safe_load .return_value = profile_dict
291+ mock_self .yaml .safe_load .return_value = profiles_dict
292+ profile = profiles_dict ["a_profile" ]
293+ mock_self .ProfileRenderer ().render_data .return_value = profile
292294 with self .assertRaises (ValueError ):
293295 _ , _ = DbtParser ._get_connection_creds (mock_self )
294296
295297 @patch ("builtins.open" , new_callable = mock_open , read_data = "" )
296298 def test_get_connection_no_target_credentials (self , mock_open ):
297- profile_dict = {
299+ profiles_dict = {
298300 "a_profile" : {
299301 "outputs" : {
300302 "a_target" : {"type" : "TYPE1" , "credential_1" : "credential_1" , "credential_2" : "credential_2" }
@@ -305,13 +307,15 @@ def test_get_connection_no_target_credentials(self, mock_open):
305307 mock_self = Mock ()
306308 mock_self .profiles_dir = ""
307309 mock_self .project_dict = {"profile" : "a_profile" }
308- mock_self .yaml .safe_load .return_value = profile_dict
310+ profile = profiles_dict ["a_profile" ]
311+ mock_self .ProfileRenderer ().render_data .return_value = profile
312+ mock_self .yaml .safe_load .return_value = profiles_dict
309313 with self .assertRaises (ValueError ):
310314 _ , _ = DbtParser ._get_connection_creds (mock_self )
311315
312316 @patch ("builtins.open" , new_callable = mock_open , read_data = "" )
313317 def test_get_connection_no_type (self , mock_open ):
314- profile_dict = {
318+ profiles_dict = {
315319 "a_profile" : {
316320 "outputs" : {"a_target" : {"credential_1" : "credential_1" , "credential_2" : "credential_2" }},
317321 "target" : "a_target" ,
@@ -320,7 +324,9 @@ def test_get_connection_no_type(self, mock_open):
320324 mock_self = Mock ()
321325 mock_self .profiles_dir = ""
322326 mock_self .project_dict = {"profile" : "a_profile" }
323- mock_self .yaml .safe_load .return_value = profile_dict
327+ mock_self .yaml .safe_load .return_value = profiles_dict
328+ profile = profiles_dict ["a_profile" ]
329+ mock_self .ProfileRenderer ().render_data .return_value = profile
324330 with self .assertRaises (ValueError ):
325331 _ , _ = DbtParser ._get_connection_creds (mock_self )
326332
@@ -366,7 +372,7 @@ def test_local_diff(self, mock_diff_tables):
366372 mock_diff_tables .assert_called_once_with (
367373 mock_table1 , mock_table2 , threaded = True , algorithm = Algorithm .JOINDIFF , extra_columns = ANY
368374 )
369- self .assertEqual (len (mock_diff_tables .call_args [1 ][' extra_columns' ]), 2 )
375+ self .assertEqual (len (mock_diff_tables .call_args [1 ][" extra_columns" ]), 2 )
370376 self .assertEqual (mock_connect .call_count , 2 )
371377 mock_connect .assert_any_call (mock_connection , "." .join (dev_qualified_list ), tuple (expected_keys ), None )
372378 mock_connect .assert_any_call (mock_connection , "." .join (prod_qualified_list ), tuple (expected_keys ), None )
@@ -393,7 +399,7 @@ def test_local_diff_no_diffs(self, mock_diff_tables):
393399 mock_diff_tables .assert_called_once_with (
394400 mock_table1 , mock_table2 , threaded = True , algorithm = Algorithm .JOINDIFF , extra_columns = ANY
395401 )
396- self .assertEqual (len (mock_diff_tables .call_args [1 ][' extra_columns' ]), 2 )
402+ self .assertEqual (len (mock_diff_tables .call_args [1 ][" extra_columns" ]), 2 )
397403 self .assertEqual (mock_connect .call_count , 2 )
398404 mock_connect .assert_any_call (mock_connection , "." .join (dev_qualified_list ), tuple (expected_keys ), None )
399405 mock_connect .assert_any_call (mock_connection , "." .join (prod_qualified_list ), tuple (expected_keys ), None )
0 commit comments