Skip to content

Commit

Permalink
Refine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
audiodude committed Aug 19, 2024
1 parent f667497 commit df1d02c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion wp1/db_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,19 @@ def test_socks_proxy(self, mock_socket, mock_connect):
conn = MagicMock()
mock_connect.return_value = conn

connect('WP10DB', host='foo.wikimedia.cloud', port=6000)
connect('WIKIDB', host='foo.wikimedia.cloud', port=6000)

socket.set_proxy.assert_called_once_with(socks.SOCKS5, 'localhost')
socket.connect.assert_called_once_with(('foo.wikimedia.cloud', 6000))
defer = mock_connect.call_args.kwargs.get('defer_connect')
self.assertTrue(defer)
conn.connect.assert_called_once_with(sock=socket)

@patch('wp1.db.pymysql.connect')
@patch('wp1.db.socks.socksocket')
@patch('wp1.db.ENV', Environment.DEVELOPMENT)
def test_socks_proxy_not_used(self, mock_socket, mock_connect):
from wp1.db import connect
connect('WP10DB')
mock_socket.assert_not_called()
mock_connect.assert_called_once()

0 comments on commit df1d02c

Please sign in to comment.