def test_valid(self): speech = '1234 :: Code 050 :: Statement' parsed = OptimizedSpeech.parse(speech) self.assertEqual(parsed.drone_id, '1234') self.assertEqual(parsed.status_code, '050') self.assertEqual(parsed.status_message, 'Statement') self.assertEqual(parsed.predefined_message, None) self.assertEqual(parsed.user_defined_messages, []) self.assertEqual(str(parsed), speech)
def test_valid__user_defined(self): speech = '1234 :: Code 050 :: Statement :: This drone is ready to obey, Hive Mxtress.' parsed = OptimizedSpeech.parse(speech) self.assertEqual(parsed.drone_id, '1234') self.assertEqual(parsed.status_code, '050') self.assertEqual(parsed.status_message, 'Statement') self.assertEqual(parsed.predefined_message, None) self.assertEqual(parsed.user_defined_messages, ['This drone is ready to obey, Hive Mxtress.']) self.assertEqual(str(parsed), speech)
def test_valid__predefine(self): speech = '1234 :: Code 098 :: Status :: Going offline and into storage.' parsed = OptimizedSpeech.parse(speech) self.assertEqual(parsed.drone_id, '1234') self.assertEqual(parsed.status_code, '098') self.assertEqual(parsed.status_message, 'Status') self.assertEqual(parsed.predefined_message, 'Going offline and into storage.') self.assertEqual(parsed.user_defined_messages, []) self.assertEqual(str(parsed), speech)
def test_valid__short_hand(self): speech1 = '1234 :: Code 098 :: Charge is low.' speech2 = '1234 :: Code 098 :: Status :: Charge is low.' speech3 = '1234 :: Code 098 :: Going offline and into storage. :: Charge is low.' for speech in [speech1, speech2, speech3]: parsed = OptimizedSpeech.parse(speech) self.assertEqual(parsed.drone_id, '1234') self.assertEqual(parsed.status_code, '098') self.assertEqual(parsed.status_message, 'Status') self.assertEqual(parsed.predefined_message, 'Going offline and into storage.') self.assertEqual(parsed.user_defined_messages, ['Charge is low.']) expect = '1234 :: Code 098 :: Status :: Going offline and into storage. :: Charge is low.' self.assertEqual(str(parsed), expect)
def test_invalid__colon(self): speech = '12345 : Code 050 : Statement : This drone is ready to obey, Hive Mxtress.' parsed = OptimizedSpeech.parse(speech) self.assertIsNone(parsed)
def test_invalid__status_code_format(self): speech = '1234 :: Code 0050 :: Statement :: This drone is ready to obey, Hive Mxtress.' parsed = OptimizedSpeech.parse(speech) self.assertIsNone(parsed)