def sendMessage(self, messageContent, source='unspecified', phase='unspecified', status='info'): """ Sends the message after creating the correct format: including content, timestamp, status, source, phase and the uuid of the pilot. Returns: bool: False in case of any errors, True otherwise """ if not self._isCorrectStatus(status): logging.error('status: ' + str(status) + ' is not correct') return False myUUID = getPilotUUIDFromFile(self.params['FileWithID']) message = generateDict(myUUID, generateTimeStamp(), source, phase, status, messageContent) if not isMessageFormatCorrect(message): logging.warning("Message format is not correct.") return False encodedMsg = encodeMessage(message) self.messageSender.sendMessage(encodedMsg, flag=status) return False
def test_cosistency( self ): result = decodeMessage( encodeMessage( self.msg ) ) self.assertEqual( result, self.msg )
def test_cosistency( self ): result = decodeMessage( encodeMessage( self.msg ) ) self.assertEqual( result, self.msg )
def test_success( self ): result = encodeMessage( self.msg ) standJSON = json.dumps( self.msg ) self.assertEqual( result, standJSON )
def test_success( self ): result = encodeMessage( self.msg ) standJSON = json.dumps( self.msg ) self.assertEqual( result, standJSON )