def test_config_radio_with_invalid_mode(self): """ Configure radio with an non supported radio mode """ radio = profile.Radio("rssi", [11], 10, num_per_channel=10) radio.mode = "invalid_mode" self.assertRaises(NotImplementedError, self.protocol.config_radio, radio)
def test_config_radio_sniffer(self): radio = profile.Radio("sniffer", [17, 15, 11], 100) self.sender.return_value = ['config_radio_sniffer', 'ACK'] ret = self.protocol._config_radio_sniffer(radio) self.sender.assert_called_with( ['config_radio_sniffer', '11,15,17', '100']) self.assertEqual(0, ret)
def test_config_radio_measure(self): radio = profile.Radio("rssi", [17, 15, 11], 100, num_per_channel=10) self.sender.return_value = ['config_radio_measure', 'ACK'] ret = self.protocol._config_radio_measure(radio) self.sender.assert_called_with( ['config_radio_measure', '11,15,17', '100', '10']) self.assertEqual(0, ret)
def test_config_radio_with_sniffer(self): """ Configure Radio with 'measure' mode """ radio = profile.Radio("sniffer", [17], 0) self.protocol._config_radio_sniffer = mock.Mock() self.protocol._config_radio_sniffer.return_value = 0 self.protocol._stop_radio = mock.Mock() self.protocol._stop_radio.return_value = 0 ret = self.protocol.config_radio(radio) self.assertEqual(0, ret) self.assertEqual(0, self.protocol._stop_radio.call_count) self.assertEqual(1, self.protocol._config_radio_sniffer.call_count)
def test_config_radio_with_measure(self): """ Configure Radio with 'measure' mode """ radio = profile.Radio("rssi", [17, 15, 11], 100, num_per_channel=10) self.protocol._config_radio_measure = mock.Mock() self.protocol._config_radio_measure.return_value = 0 self.protocol._stop_radio = mock.Mock() self.protocol._stop_radio.return_value = 0 ret = self.protocol.config_radio(radio) self.assertEqual(0, ret) self.assertEqual(0, self.protocol._stop_radio.call_count) self.assertEqual(1, self.protocol._config_radio_measure.call_count)
def test_config_radio_error_during_config(self): radio = profile.Radio("rssi", [11], 10, num_per_channel=10) self.protocol._config_radio_measure = mock.Mock() self.protocol._config_radio_measure.return_value = 0xFF self.protocol._stop_radio = mock.Mock() self.protocol._stop_radio.return_value = 0 ret = self.protocol.config_radio(radio) self.assertEqual(0xFF, ret) self.assertEqual(0, self.protocol._stop_radio.call_count) self.assertEqual(1, self.protocol._config_radio_measure.call_count)