def test__try_construct_envelope_positive(self, *mocks): """Test _try_construct_envelope for positive result.""" dialogues_mock = mock.Mock() msg_mock = mock.Mock(spec=DefaultMessage) msg_mock.to = "to" msg_mock.sender = "sender" dialogues_mock.create.return_value = msg_mock, None message_class = mock.Mock() envelope = _try_construct_envelope("agent_name", dialogues_mock, message_class) self.assertIsInstance(envelope, Envelope)
def test__try_construct_envelope_exception_raised(self, *mocks): """Test _try_construct_envelope for exception raised result.""" envelope = _try_construct_envelope("agent_name", "sender", "dialogues") self.assertEqual(envelope, None)
def test__try_construct_envelope_keyboard_interrupt(self, *mocks): """Test _try_construct_envelope for keyboard interrupt result.""" with self.assertRaises(KeyboardInterrupt): _try_construct_envelope("agent_name", "sender", "dialogues")
def test__try_construct_envelope_positive_no_input_message(self, *mocks): """Test _try_construct_envelope for no input message result.""" envelope = _try_construct_envelope("agent_name", "sender", "dialogues") self.assertEqual(envelope, None)
def test__try_construct_envelope_positive(self, *mocks): """Test _try_construct_envelope for positive result.""" envelope = _try_construct_envelope("agent_name", "sender", mock.Mock()) self.assertIsInstance(envelope, Envelope)