diff --git a/wp1/db_test.py b/wp1/db_test.py index eebd0d56..6587a0bb 100644 --- a/wp1/db_test.py +++ b/wp1/db_test.py @@ -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()