def test_opts_parsing_m3(prof_m3_class): """ Test that M3profile parsing matches profile class Check that default values are ok and that values are correctly passed """ # keep 'choices' valid for argparse prof_m3_class.choices = profile.ProfileM3.choices profilem3 = prof_m3_class.return_value parser = profile_parser.parse_options() args = ['addm3', '-n', 'name', '-p', 'dc'] opts = parser.parse_args(args) profile_parser._m3_profile(opts) # pylint: disable=protected-access profilem3.set_consumption.assert_called_with( period=None, average=None, power=False, voltage=False, current=False) profilem3.set_radio.assert_called_with( mode=None, channels=None, period=None, num_per_channel=0) args += ['-period', '140', '-avg', '1', '-power', '-voltage', '-current'] args += ['-rssi', '-channels', '11', '12', '13', '-num', '1', '-rperiod', '1'] opts = parser.parse_args(args) profile_parser._m3_profile(opts) # pylint: disable=protected-access profilem3.set_consumption.assert_called_with( period=140, average=1, power=True, voltage=True, current=True) profilem3.set_radio.assert_called_with( mode='rssi', channels=[11, 12, 13], period=1, num_per_channel=1)
def test_opts_parsing_m3(self, prof_m3_class, circuit_mock): """ Test that M3profile parsing matches profile class Check that default values are ok and that values are correctly passed """ # keep 'choices' valid for argparse prof_m3_class.choices = profile.ProfileM3.choices profilem3 = prof_m3_class.return_value parser = profile_parser.parse_options() args = ['addm3', '-n', 'name', '-p', 'dc'] opts = parser.parse_args(args) profile_parser._m3_profile(opts) # pylint: disable=protected-access profilem3.set_consumption.assert_called_with( period=None, average=None, power=False, voltage=False, current=False) profilem3.set_radio.assert_called_with( mode=None, channels=None, period=None, num_per_channel=None) self.assertEqual(profilem3.mobility, None) # Test for RSSI args = ['addm3', '-n', 'name', '-p', 'dc'] args += ['-period', '140', '-avg', '1', '-power', '-voltage', '-current'] args += ['-rssi', '-channels', '11', '12', '13', '-num', '1', '-rperiod', '1'] opts = parser.parse_args(args) profile_parser._m3_profile(opts) # pylint: disable=protected-access profilem3.set_consumption.assert_called_with( period=140, average=1, power=True, voltage=True, current=True) profilem3.set_radio.assert_called_with( mode='rssi', channels=[11, 12, 13], period=1, num_per_channel=1) self.assertEqual(profilem3.mobility, None) # Test for Radio Sniffer only args = ['addm3', '-n', 'name', '-p', 'dc'] args += ['-sniffer', '-channels', '11'] opts = parser.parse_args(args) profile_parser._m3_profile(opts) # pylint: disable=protected-access profilem3.set_consumption.assert_called_with( period=None, average=None, power=False, voltage=False, current=False) profilem3.set_radio.assert_called_with( mode='sniffer', channels=[11], period=None, num_per_channel=None) self.assertEqual(profilem3.mobility, None) # Test for mobility only # required fields circuit = {"site_name": "devgrenoble", "trajectory_name": "Jhall"} circuit_mock.return_value = circuit args = ['addm3', '-n', 'name', '-p', 'dc'] args += ['--circuit', 'grenoble,Jhall'] opts = parser.parse_args(args) profile_parser._m3_profile(opts) # pylint: disable=protected-access self.assertEqual(profilem3.mobility, circuit)
def test_opts_parsing_m3(prof_m3_class): """ Test that M3profile parsing matches profile class Check that default values are ok and that values are correctly passed """ # keep 'choices' valid for argparse prof_m3_class.choices = profile.ProfileM3.choices profilem3 = prof_m3_class.return_value parser = profile_parser.parse_options() args = ['addm3', '-n', 'name', '-p', 'dc'] opts = parser.parse_args(args) profile_parser._m3_profile(opts) # pylint: disable=protected-access profilem3.set_consumption.assert_called_with(period=None, average=None, power=False, voltage=False, current=False) profilem3.set_radio.assert_called_with(mode=None, channels=None, period=None, num_per_channel=0) args += [ '-period', '140', '-avg', '1', '-power', '-voltage', '-current' ] args += [ '-rssi', '-channels', '11', '12', '13', '-num', '1', '-rperiod', '1' ] opts = parser.parse_args(args) profile_parser._m3_profile(opts) # pylint: disable=protected-access profilem3.set_consumption.assert_called_with(period=140, average=1, power=True, voltage=True, current=True) profilem3.set_radio.assert_called_with(mode='rssi', channels=[11, 12, 13], period=1, num_per_channel=1)