Skip to content

Commit

Permalink
fix the mock_get_conn function , so it will really mock the data and …
Browse files Browse the repository at this point in the history
…will return empty results
  • Loading branch information
bareketamir committed Nov 11, 2024
1 parent f919c26 commit fa32482
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions tests/providers/mysql/transfers/test_vertica_to_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,26 @@


def mock_get_conn():

class MockCol:
def __init__(self, name):
self.name = name

col_a = MockCol(name="a")
col_b = MockCol(name="b")
col_c = MockCol(name="c")

commit_mock = mock.MagicMock()
cursor_mock = mock.MagicMock(
execute=[],
fetchall=[["1", "2", "3"]],
description=["a", "b", "c"],
iterate=[["1", "2", "3"]],
)
conn_mock = mock.MagicMock(
commit=commit_mock,
cursor=cursor_mock,
description = [col_a, col_b, col_c]
)
cursor_mock.execute.return_value=[]
cursor_mock.fetchall.return_value=[["1", "2", "3"]]
cursor_mock.iterate.return_value=[["1", "2", "3"]]
conn_mock = mock.MagicMock()
conn_mock.commit.return_value = commit_mock
conn_mock.cursor.return_value = cursor_mock

return conn_mock


Expand Down

0 comments on commit fa32482

Please sign in to comment.