def test_is_parameter_present(self): data_model = BaicellsTrDataModel() with self.assertRaises(KeyError): data_model.is_parameter_present(ParameterName.GPS_LONG) result = data_model.is_parameter_present(ParameterName.DEVICE) self.assertTrue(result, "Should have the device parameter")
def test_get_numbered_param_names(self): name_list = list(BaicellsTrDataModel.get_numbered_param_names().keys()) # Check that unnumbered parameters are missing self.assertNotIn( ParameterName.EARFCNDL, name_list, 'Should not have %s in parameter name list' % ParameterName.EARFCNDL, ) self.assertNotIn( ParameterName.MME_PORT, name_list, 'Should not have %s in parameter name list' % ParameterName.MME_PORT, ) self.assertNotIn( ParameterName.PERIODIC_INFORM_ENABLE, name_list, 'Should not have %s in parameter name list' % ParameterName.PERIODIC_INFORM_ENABLE, ) # Check that some numbered parameters are present self.assertIn( ParameterName.PLMN_N % 1, name_list, 'Should have %s in parameter name list' % ParameterName.PLMN_N % 1, ) self.assertIn( ParameterName.PLMN_N % 6, name_list, 'Should have %s in parameter name list' % ParameterName.PLMN_N % 6, )
def test_get_parameter_names(self): name_list = BaicellsTrDataModel.get_parameter_names() # Check that some random parameter names we expect are there self.assertIn( ParameterName.MME_STATUS, name_list, 'Should have %s in parameter name list' % ParameterName.MME_STATUS, ) self.assertIn( ParameterName.DUPLEX_MODE_CAPABILITY, name_list, 'Should have %s in parameter name list' % ParameterName.DUPLEX_MODE_CAPABILITY, ) self.assertIn( ParameterName.EARFCNUL, name_list, 'Should have %s in parameter name list' % ParameterName.EARFCNUL, ) # Check that some other parameter names are missing self.assertNotIn( ParameterName.PLMN, name_list, 'Should not have %s in parameter name list' % ParameterName.PLMN, ) self.assertNotIn( ParameterName.PLMN_N % 1, name_list, 'Should not have %s in parameter name list' % ParameterName.PLMN_N % 1, )
def test_transform_for_enb(self): dl_bandwidth = 15 dl_bandwidth_enb = BaicellsTrDataModel.transform_for_enb( ParameterName.DL_BANDWIDTH, dl_bandwidth) expected = 'n75' self.assertEqual(dl_bandwidth_enb, expected, 'Transform for enb returning incorrect value')
def test_transform_for_magma(self): gps_lat = str(10 * 1000000) gps_lat_magma = BaicellsTrDataModel.transform_for_magma( ParameterName.GPS_LAT, gps_lat, ) expected = str(10.0) self.assertEqual(gps_lat_magma, expected)
def test_get_parameter(self): param_info =\ BaicellsTrDataModel.get_parameter(ParameterName.GPS_STATUS) self.assertIsNotNone( param_info, 'Cannot get parameter info on %s' % ParameterName.GPS_STATUS) path = param_info.path expected_path = 'Device.DeviceInfo.X_BAICELLS_COM_GPS_Status' self.assertEqual( path, expected_path, 'Path for parameter %s has incorrect value' % ParameterName.GPS_STATUS)
def setUp(self): self.data_model = BaicellsTrDataModel() self.cfg = EnodebConfiguration(BaicellsTrDataModel()) self.device_cfg = EnodebConfiguration(BaicellsTrDataModel())
class EnodebConfigurationFactoryTest(TestCase): def setUp(self): self.data_model = BaicellsTrDataModel() self.cfg = EnodebConfiguration(BaicellsTrDataModel()) self.device_cfg = EnodebConfiguration(BaicellsTrDataModel()) def tearDown(self): self.data_model = None self.cfg = None self.device_cfg = None def test_set_pci(self): pci = 3 _set_pci(self.cfg, pci) self.assertEqual(self.cfg.get_parameter(ParameterName.PCI), pci, 'PCI value should be same as what was set') with self.assertRaises(ConfigurationError): _set_pci(self.cfg, 505) def test_set_bandwidth(self): mhz = 15 _set_bandwidth(self.cfg, self.data_model, mhz) self.assertEqual(self.cfg.get_parameter(ParameterName.DL_BANDWIDTH), mhz, 'Should have set %s' % ParameterName.DL_BANDWIDTH) self.assertEqual(self.cfg.get_parameter(ParameterName.UL_BANDWIDTH), mhz, 'Should have set %s' % ParameterName.UL_BANDWIDTH) def test_set_tdd_subframe_config(self): # Not TDD mode, should not try to set anything self.device_cfg.set_parameter(ParameterName.DUPLEX_MODE_CAPABILITY, 'Not TDDMode') subframe = 0 special_subframe = 0 _set_tdd_subframe_config(self.device_cfg, self.cfg, subframe, special_subframe) self.assertTrue(ParameterName.SUBFRAME_ASSIGNMENT not in self.cfg.get_parameter_names()) # Invalid subframe assignment self.device_cfg.set_parameter(ParameterName.DUPLEX_MODE_CAPABILITY, 'TDDMode') _set_tdd_subframe_config(self.device_cfg, self.cfg, subframe, special_subframe) self.assertIn(ParameterName.SUBFRAME_ASSIGNMENT, self.cfg.get_parameter_names(), 'Expected a subframe assignment') def test_set_management_server(self): _set_management_server(self.cfg) self.assertEqual( self.cfg.get_parameter(ParameterName.PERIODIC_INFORM_ENABLE), True, 'Expected periodic inform enable to be true') self.assertTrue( isinstance( self.cfg.get_parameter(ParameterName.PERIODIC_INFORM_INTERVAL), int), 'Expected periodic inform interval to ani integer') def test_set_s1_connection(self): invalid_mme_ip = 1234 invalid_mme_port = '8080' mme_ip = '192.168.0.1' mme_port = 8080 # MME IP should be a string with self.assertRaises(ConfigurationError): _set_s1_connection(self.cfg, invalid_mme_ip, mme_port) # MME Port should be an integer with self.assertRaises(ConfigurationError): _set_s1_connection(self.cfg, mme_ip, invalid_mme_port) # Check the ip and port are sort properly _set_s1_connection(self.cfg, mme_ip, mme_port) self.assertEqual(self.cfg.get_parameter(ParameterName.MME_IP), mme_ip, 'Expected mme ip to be set') self.assertEqual(self.cfg.get_parameter(ParameterName.MME_PORT), mme_port, 'Expected mme port to be set') def test_set_perf_mgmt(self): mgmt_ip = '192.168.0.1' mgmt_upload_interval = 300 mgmt_port = 8080 _set_perf_mgmt(self.cfg, mgmt_ip, mgmt_port) self.assertTrue(self.cfg.get_parameter(ParameterName.PERF_MGMT_ENABLE), 'Expected perf mgmt to be enabled') self.assertEqual( self.cfg.get_parameter(ParameterName.PERF_MGMT_UPLOAD_INTERVAL), mgmt_upload_interval, 'Expected upload interval to be set') expected_url = 'http://192.168.0.1:8080/' self.assertEqual( self.cfg.get_parameter(ParameterName.PERF_MGMT_UPLOAD_URL), expected_url, 'Incorrect Url') def test_set_misc_static_params(self): # IPSec enable as integer self.device_cfg.set_parameter(ParameterName.IP_SEC_ENABLE, 0) self.data_model.set_parameter_presence(ParameterName.GPS_ENABLE, True) _set_misc_static_params(self.device_cfg, self.cfg, self.data_model) self.assertTrue( isinstance(self.cfg.get_parameter(ParameterName.IP_SEC_ENABLE), int), 'Should support an integer IP_SEC_ENABLE parameter') # IPSec enable as boolean self.device_cfg.set_parameter(ParameterName.IP_SEC_ENABLE, 'False') _set_misc_static_params(self.device_cfg, self.cfg, self.data_model) self.assertTrue( isinstance(self.cfg.get_parameter(ParameterName.IP_SEC_ENABLE), bool), 'Should support a boolean IP_SEC_ENABLE parameter') self.assertEqual( self.cfg.get_parameter(ParameterName.LOCAL_GATEWAY_ENABLE), 0, 'Should be disabled') self.assertEqual(self.cfg.get_parameter(ParameterName.CELL_RESERVED), False, 'Should be disabled') self.assertEqual(self.cfg.get_parameter(ParameterName.MME_POOL_ENABLE), False, 'Should be disabled') def test_set_plmnids_tac(self): # We only handle a single PLMNID for now plmnids = '1, 2, 3, 4' tac = 1 with self.assertRaises(ConfigurationError): _set_plmnids_tac(self.cfg, plmnids, tac) # Max PLMNID length is 6 characters plmnids = '1234567' with self.assertRaises(ConfigurationError): _set_plmnids_tac(self.cfg, plmnids, tac) # Check that only one PLMN element is enabled plmnids = '1' _set_plmnids_tac(self.cfg, plmnids, tac) self.assertTrue( self.cfg.get_parameter_for_object(ParameterName.PLMN_N_ENABLE % 1, ParameterName.PLMN_N % 1), 'First PLMN should be enabled') self.assertFalse(self.cfg.has_object(ParameterName.PLMN_N % 2), 'Second PLMN should be disabled') def test_set_earafcn_freq_band_mode(self): # Invalid earfcndl with self.assertRaises(ConfigurationError): invalid_earfcndl = -1 _set_earfcn_freq_band_mode(self.device_cfg, self.cfg, self.data_model, invalid_earfcndl) # Duplex_mode is TDD but capability is FDD with self.assertRaises(ConfigurationError): self.device_cfg.set_parameter(ParameterName.DUPLEX_MODE_CAPABILITY, 'FDDMode') earfcndl = 38650 # Corresponds to TDD _set_earfcn_freq_band_mode(self.device_cfg, self.cfg, self.data_model, earfcndl) # Duplex_mode is FDD but capability is TDD with self.assertRaises(ConfigurationError): self.device_cfg.set_parameter(ParameterName.DUPLEX_MODE_CAPABILITY, 'TDDMode') earfcndl = 0 # Corresponds to FDD _set_earfcn_freq_band_mode(self.device_cfg, self.cfg, self.data_model, earfcndl) def test_get_enb_config(self): mconfig = EnodebConfigBuilder.get_mconfig() enb_config = _get_enb_config(mconfig, self.device_cfg) self.assertTrue(enb_config.earfcndl == 39150, "Should give earfcndl from default eNB config") mconfig = EnodebConfigBuilder.get_multi_enb_mconfig() self.device_cfg.set_parameter(ParameterName.SERIAL_NUMBER, '120200002618AGP0003') enb_config = _get_enb_config(mconfig, self.device_cfg) self.assertTrue(enb_config.earfcndl == 39151, "Should give earfcndl from specific eNB config")
def test_get_num_plmns(self): n_plmns = BaicellsTrDataModel.get_num_plmns() expected_n_plmns = 6 self.assertEqual(n_plmns, expected_n_plmns, 'Incorrect # of PLMNs')