@@ -1271,7 +1271,7 @@ def test_verify_tags(self):
12711271 @mock .patch (PATH + "find_username" )
12721272 @mock .patch (PATH + "check_comments_for_duplicate" )
12731273 @mock .patch ("jira.client.JIRA" )
1274- @mock .patch ("sync2jira.downstream_issue. execute_snowflake_query" )
1274+ @mock .patch (PATH + " execute_snowflake_query" )
12751275 def test_matching_jira_issue_query (
12761276 self ,
12771277 mock_snowflake ,
@@ -1641,38 +1641,24 @@ def test_remove_diacritics(self):
16411641 actual = remove_diacritics (text )
16421642 self .assertEqual (actual , expected )
16431643
1644- @mock .patch ("sync2jira.downstream_issue. snowflake.connector.connect" )
1644+ @mock .patch (PATH + " snowflake.connector.connect" )
16451645 def test_execute_snowflake_query_real_connection (self , mock_snowflake_connect ):
16461646 """
16471647 Test execute_snowflake_query with real Snowflake connection to cover the 10 lines
16481648 that are currently mocked out in other tests.
16491649 """
1650- # Set up mock Snowflake connection and cursor
1651- mock_conn = MagicMock ()
1652- mock_cursor = MagicMock ()
1653- mock_conn .cursor .return_value = mock_cursor
1654- mock_conn .__enter__ = MagicMock (return_value = mock_conn )
1655- mock_conn .__exit__ = MagicMock (return_value = None )
1656- mock_snowflake_connect .return_value = mock_conn
1657-
1658- # Mock the query results
1659- mock_results = [
1660- ("SYNC2JIRA-123" , "https://github.com/test/repo/issues/1" , "2023-01-01" )
1661- ]
1662- mock_cursor .fetchall .return_value = mock_results
1663-
16641650 # Create a mock issue
16651651 mock_issue = MagicMock ()
16661652 mock_issue .url = "https://github.com/test/repo/issues/1"
1667-
16681653 # Call the function
16691654 result = d .execute_snowflake_query ("Test Title" , mock_issue )
1670-
1655+ mock_cursor = (
1656+ mock_snowflake_connect .return_value .__enter__ .return_value .cursor .return_value
1657+ )
16711658 # Assert the function was called correctly
16721659 mock_snowflake_connect .assert_called_once ()
16731660 mock_cursor .execute .assert_called_once ()
16741661 mock_cursor .fetchall .assert_called_once ()
16751662 mock_cursor .close .assert_called_once ()
1676-
16771663 # Assert the result
1678- self .assertEqual (result , mock_results )
1664+ self .assertEqual (result , mock_cursor . fetchall . return_value )
0 commit comments