def test_get_meas_group_with_nfs_api(self): sub = create_subscription_data('sub1') nf_list = create_multiple_network_function_data(['pnf101', 'pnf102']) measurement_group_service.save_measurement_group( sub.measurement_groups[0].serialize()['measurementGroup'], sub.subscription_name) for nf in nf_list: nf_service.save_nf(nf) measurement_group_service. \ apply_nf_status_to_measurement_group(nf.nf_name, sub.measurement_groups[0]. measurement_group_name, MgNfState.PENDING_CREATE.value) db.session.commit() mg_with_nfs, status_code = get_meas_group_with_nfs('sub1', 'MG1') self.assertEqual(status_code, HTTPStatus.OK.value) self.assertEqual(mg_with_nfs['subscriptionName'], 'sub1') self.assertEqual(mg_with_nfs['measurementGroupName'], 'MG1') self.assertEqual(mg_with_nfs['administrativeState'], 'UNLOCKED') self.assertEqual(len(mg_with_nfs['networkFunctions']), 2)
def test_update_admin_state_api_for_locked_update(self): sub = create_subscription_data('sub1') nf_list = create_multiple_network_function_data(['pnf_101', 'pnf_102']) db.session.add(sub) for nf in nf_list: nf_service.save_nf(nf) measurement_group_service. \ apply_nf_status_to_measurement_group(nf.nf_name, sub.measurement_groups[0]. measurement_group_name, MgNfState.CREATED.value) db.session.commit() response = update_admin_state('sub1', 'MG1', {'administrativeState': 'LOCKED'}) self.assertEqual(response[1], HTTPStatus.OK.value) self.assertEqual(response[0], 'Successfully updated admin state') mg_with_nfs, status_code = get_meas_group_with_nfs('sub1', 'MG1') self.assertEqual(mg_with_nfs['subscriptionName'], 'sub1') self.assertEqual(mg_with_nfs['measurementGroupName'], 'MG1') self.assertEqual(mg_with_nfs['administrativeState'], 'LOCKING') for nf in mg_with_nfs['networkFunctions']: self.assertEqual(nf['nfMgStatus'], MgNfState.PENDING_DELETE.value)
def test_update_admin_state_api_for_unlocked_update( self, mock_filter_call, mock_model_aai, mock_aai): mock_aai.return_value = json.loads(self.aai_response_data) mock_model_aai.return_value = json.loads(self.good_model_info) sub = create_subscription_data('sub1') db.session.add(sub) nf_list = create_multiple_network_function_data(['pnf_101', 'pnf_102']) for network_function in nf_list: db.session.add(network_function) db.session.commit() mock_filter_call.return_value = NetworkFunctionFilter.get_network_function_filter( 'sub') response = update_admin_state('sub1', 'MG2', {'administrativeState': 'UNLOCKED'}) self.assertEqual(response[1], HTTPStatus.OK.value) self.assertEqual(response[0], 'Successfully updated admin state') mg_with_nfs, status_code = get_meas_group_with_nfs('sub1', 'MG2') self.assertEqual(mg_with_nfs['subscriptionName'], 'sub1') self.assertEqual(mg_with_nfs['measurementGroupName'], 'MG2') self.assertEqual(mg_with_nfs['administrativeState'], 'UNLOCKED') for nf in mg_with_nfs['networkFunctions']: self.assertEqual(nf['nfMgStatus'], MgNfState.PENDING_CREATE.value)
def test_get_meas_group_with_nfs_api_exception(self): error, status_code = get_meas_group_with_nfs('sub1', 'MG1') self.assertEqual(status_code, HTTPStatus.INTERNAL_SERVER_ERROR.value)
def test_get_meas_group_with_nfs_api_none(self): error, status_code = get_meas_group_with_nfs('sub1', 'MG1') self.assertEqual( error['error'], 'measurement group was not defined with ' 'the sub name: sub1 and meas group name: MG1') self.assertEqual(status_code, HTTPStatus.NOT_FOUND.value)