def test_make_socket_connection_socket_error(self, mock_socket): mock_socket.side_effect = TcpSocketError self.assertEqual(Diagnostics.state, DiagState.CLOSED) # with self.assertRaises(DiagnosticsError): Diagnostics._make_socket_connection(5570) self.assertEqual(Diagnostics.state, DiagState.CLOSED)
def test_make_socket_wait_error(self, mock_socket): ms = Mock() mock_socket.return_value = ms ms.wait_for_connection.side_effect = TcpSocketError self.assertEqual(Diagnostics.state, DiagState.CLOSED) #with self.assertRaises(DiagnosticsError): Diagnostics._make_socket_connection(5570) self.assertEqual(Diagnostics.state, DiagState.CLOSED)
def test_make_socket_connection(self, mock_socket, mock_thread): ms = Mock() mock_socket.return_value = ms self.assertEqual(Diagnostics.state, DiagState.CLOSED) Diagnostics._make_socket_connection(5570) mock_socket.assert_called_with(5570) ms.wait_for_connection.assert_called_with() ms.set_max_recv_bytes.assert_called_with(1024) self.assertEqual(Diagnostics.state, DiagState.ESTABLISHED) Diagnostics.state = DiagState.CLOSED