def test_insert_api(self): insert_params = { 'create_id': 'test_create_id-0ac6cb428b23', 'update_id': 'test_create_id-0ac6cb428b23', 'delete_flg': 0, 'tenant_name': 'tenant_name001', 'contract_kind': 1, 'apl_type': 1, 'type': 1, 'device_type': 1, 'redundant_configuration_flg': '0', 'type_detail_info': '{}', 'contract': 2 } request_params = { 'body': insert_params, 'query': {}, 'resource': 'contracts', 'method': 'POST', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertTrue('ID' in res_data) # Assertion(check select) request_params = { 'query': { 'contract_kind': 1, 'apl_type': 1, 'type': 1, 'device_type': 1, 'redundant_configuration_flg': '0', }, 'resource': 'contracts', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in insert_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(insert_params[key])) else: self.assertEqual(res_data[0].get(key), insert_params[key])
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'tenant_id': 'tenant_id-ad4c-4cc6ea276a55', 'apl_type': '2', 'port_id': 'port_id-ad4c-4cc6ea276a55', 'IaaS_port_id': 'IaaS_port_id-ad4c-4cc6ea276a55', 'IaaS_subnet_id': 'IaaS_subnet_id_xxxxxxxxxx', 'IaaS_subnet_id_v6': 'IaaS_subnet_id_v6_xxxxxxxxxx', 'node_id': 'apl_id-ad4c-4cc6ea276a55', 'network_id': 'network_id-ad4c-4cc6ea276a55', 'nic': 'nic', 'ip_address': '10.20.70.40', 'netmask': 24, 'ip_address_v6': 'dead:beaf::3', 'netmask_v6': 48, 'port_info': '{}', 'msa_info': '{}', 'network_type': 1 } request_params = { 'body': update_params, 'query': {}, 'resource': 'ports', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': { 'port_id': 'port_id-ad4c-4cc6ea276a55', }, 'resource': 'ports', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: self.assertEqual(res_data[0].get(key), update_params[key])
def test_insert_api(self): insert_params = { 'create_id': 'test_create_id-0ac6cb428b23', 'update_id': 'test_update_id-0ac6cb428b23', 'delete_flg': 0, 'license': 'license', 'type': 1, 'device_type': 1, 'type_detail': 1, 'status': 0, 'tenant_name': 'tenant_id-bb6d-6bb9bd380a11', 'node_id': 'node_id-bb6d-6bb9bd380a11' } request_params = { 'body': insert_params, 'query': {}, 'resource': 'licenses', 'method': 'POST', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertTrue('ID' in res_data) # Assertion(check select) request_params = { 'query': { 'license': 'license', 'type': 1, 'device_type': 1, 'type_detail': 1, }, 'resource': 'licenses', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in insert_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(insert_params[key])) else: self.assertEqual(res_data[0].get(key), insert_params[key])
def test_insert_api(self): insert_params = { 'create_id': 'test_create_id-0ac6cb428b23', 'update_id': 'test_create_id-0ac6cb428b23', 'delete_flg': 0, 'pod_id': 'pod_id-bb6d-6bb9bd380a11', 'use_type': 3, 'ops_version': 2, 'weight': 5, 'region_id': 'regionTwo', } request_params = { 'body': insert_params, 'query': {}, 'resource': 'pods', 'method': 'POST', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertTrue('ID' in res_data) # Assertion(check select) request_params = { 'query': { 'pod_id': 'pod_id-bb6d-6bb9bd380a11', }, 'resource': 'pods', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['update_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['delete_flg'], '0') self.assertEqual(res_data[0]['pod_id'], 'pod_id-bb6d-6bb9bd380a11') self.assertEqual(res_data[0].get('extension_info', ''), '') self.assertEqual(res_data[0]['use_type'], 3) self.assertEqual(res_data[0]['ops_version'], 2) self.assertEqual(res_data[0]['weight'], 5) self.assertEqual(res_data[0]['region_id'], 'regionTwo')
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'group_id': 'group_id-ad4c-4cc6ea276a55', 'dc_id': 'dc_id-ad4c-4cc6ea276a55', 'tenant_id': 'tenant_id-ad4c-4cc6ea276a55', 'wan_network_id': 'wan_network_id-ad4c-4cc6ea276a55', 'ce1_info': '{}', 'ce2_info': '{}', 'IaaS_network_type': 'xlan', 'IaaS_network_id': 'IaaS_network_id-ad4c-4cc6ea276a55', 'IaaS_segmentation_id': 'IaaS_segmentation_id-ad4c-4cc6ea276a55', 'IaaS_subnet_id': 'IaaS_subnet_id_xxxxxxxxxx', 'IaaS_subnet_id_v6': 'IaaS_subnet_id_v6_xxxxxxxxxx', 'vrrp_address_v6': 'dead:beaf::1', 'ce1_address_v6': 'dead:beaf::2', 'ce2_address_v6': 'dead:beaf::3', } request_params = { 'body': update_params, 'query': {}, 'resource': 'dc-con-members', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': {}, 'resource': 'dc-con-members', 'method': 'GET', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(update_params[key])) else: self.assertEqual(res_data[0].get(key), update_params[key])
def test_insert_api(self): insert_params = { 'create_id': 'test_create_id-0ac6cb428b23', 'update_id': 'test_create_id-0ac6cb428b23', 'delete_flg': 0, 'network_id': 'network_id-bb6d-6bb9bd380a11', } insert_params.update(extension_info) request_params = { 'body': insert_params, 'query': {}, 'resource': 'vlans', 'method': 'POST', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertTrue('ID' in res_data) # Assertion(check select) request_params = { 'query': { 'network_id': 'network_id-bb6d-6bb9bd380a11', }, 'resource': 'vlans', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in insert_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(insert_params[key])) else: self.assertEqual(res_data[0].get(key), insert_params[key]) assert_info = json.loads(extension_info['nal_vlan_info']) nal_vlan_info = json.loads(res_data[0]['nal_vlan_info']) for key in assert_info: self.assertEqual(nal_vlan_info.get(key), assert_info[key])
def test_insert_api(self): insert_params = { 'create_id': 'test_create_id-0ac6cb428b23', 'update_id': 'test_create_id-0ac6cb428b23', 'delete_flg': 0, 'dc_id': 'dc102', 'ce01_ip_address': '11.0.0.1', 'ce02_ip_address': '11.0.0.2', 'network_address': '11.0.0.0', 'netmask': 24, 'status': 1, 'group_id': 'group999', } request_params = { 'body': insert_params, 'query': {}, 'resource': 'dc-segment', 'method': 'POST', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertTrue('ID' in res_data) # Assertion(check select) request_params = { 'query': { 'dc_id': 'dc102', }, 'resource': 'dc-segment', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') print(res_data) self.assertEqual(len(res_data), 1) for key in insert_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(insert_params[key])) else: self.assertEqual(res_data[0].get(key), insert_params[key])
def test_insert_api(self): insert_params = { 'create_id': 'test_create_id-0ac6cb428b23', 'update_id': 'test_update_id-0ac6cb428b23', 'delete_flg': 0, 'type': 1, 'dc_id': 'dc_01', 'region_id': 'region_id_0001', 'pod_id': 'pod_id_0001', 'config_info': '{"xxx":"xxxxx","bbb":"bbbbbb","ccc":"ccccccc"}', } request_params = { 'body': insert_params, 'query': {}, 'resource': 'wim-configs', 'method': 'POST', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertTrue('ID' in res_data) # Assertion(check select) request_params = { 'query': { 'type': 1, 'dc_id': 'dc_01', 'region_id': 'region_id_0001', 'pod_id': 'pod_id_0001', }, 'resource': 'wim-configs', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in insert_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(insert_params[key])) else: self.assertEqual(res_data[0].get(key), insert_params[key])
def test_update_api(self): update_params = { 'update_id': 'test_update_id-12', 'global_ip': '10.50.60.52', 'status': "", 'tenant_name': 'tenant_id-ad4c-4cc6ea276a55', 'node_id': 'node_id-ad4c-4cc6ea276a55' } request_params = { 'request_id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'body': update_params, 'query': {}, 'resource': 'global-ip-addresses', 'method': 'PUT', 'id': [ID1] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # select check request_params = { 'resource': 'global-ip-addresses', 'method': 'GET', 'id': [ID1] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Check to get number self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) # Check the contents of the data self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['update_id'], 'test_update_id-12') self.assertEqual(res_data[0]['delete_flg'], '0') self.assertEqual(res_data[0]['global_ip'], '10.50.60.52') self.assertEqual(res_data[0].get('extension_info', ''), '') self.assertEqual(res_data[0]['status'], '') self.assertEqual(res_data[0]['node_id'], 'node_id-ad4c-4cc6ea276a55') self.assertEqual(res_data[0]['tenant_name'], 'tenant_id-ad4c-4cc6ea276a55')
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'license': 'license', 'type': 2, 'device_type': 2, 'type_detail': 2, 'status': 1, 'tenant_name': 'tenant_id-ad4c-4cc6ea276a55', 'node_id': 'node_id-ad4c-4cc6ea276a55' } request_params = { 'body': update_params, 'query': {}, 'resource': 'licenses', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': { 'license': 'license', 'type': 2, 'device_type': 2, 'type_detail': 2, 'status': 1, }, 'resource': 'licenses', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(update_params[key])) else: self.assertEqual(res_data[0].get(key), update_params[key])
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'tenant_id': 'tenant_id-ad4c-4cc6ea276a55', 'network_id': 'network_id-ad4c-4cc6ea276a55', 'vlan_id': 502 } update_params.update(extension_info) request_params = { 'body': update_params, 'query': {}, 'resource': 'vlans', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': { 'network_id': 'network_id-ad4c-4cc6ea276a55', }, 'resource': 'vlans', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(update_params[key])) else: self.assertEqual(res_data[0].get(key), update_params[key]) assert_info = json.loads(extension_info['nal_vlan_info']) nal_vlan_info = json.loads(res_data[0]['nal_vlan_info']) for key in assert_info: self.assertEqual(nal_vlan_info.get(key), assert_info[key])
def test_insert_api(self): insert_params = { 'create_id': 'test_create_id-0ac6cb428b23', 'update_id': 'test_create_id-0ac6cb428b23', 'delete_flg': 0, 'dc_id': 'dc_02', 'pod_id': 'pod_id-1564dsf1d56-as1f56a-das15d6', 'vlan_id': 103, 'status': 0, 'group_id': 'group_id-gsa8t1-y65b4184-gh65b', } request_params = { 'body': insert_params, 'query': {}, 'resource': 'dc-vlans', 'method': 'POST', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertTrue('ID' in res_data) # Assertion(check select) request_params = { 'query': { 'dc_id': 'dc_02', 'pod_id': 'pod_id-1564dsf1d56-as1f56a-das15d6', 'vlan_id': 103, }, 'resource': 'dc-vlans', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in insert_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(insert_params[key])) else: self.assertEqual(res_data[0].get(key), insert_params[key])
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'tenant_name': 'tenant_name002', 'contract_kind': 2, 'apl_type': 2, 'type': 2, 'device_type': 2, 'redundant_configuration_flg': '1', 'type_detail_info': '{"type_detail": {"1": "1"}}', 'contract': 3 } request_params = { 'body': update_params, 'query': {}, 'resource': 'contracts', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': { 'contract_kind': 2, 'apl_type': 2, 'type': 2, 'device_type': 2, 'redundant_configuration_flg': '1', }, 'resource': 'contracts', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: self.assertEqual(res_data[0].get(key), update_params[key])
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'type': 3, 'dc_id': 'dc_05', 'region_id': 'region_id_0007', 'pod_id': 'pod_id_0007', 'endpoint_info': '{"vvv":"vvvvvv","bbb":"bbbbbb","ccc":"ccccccc"}', } request_params = { 'body': update_params, 'query': {}, 'resource': 'wim-endpoints', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': { 'type': 3, 'dc_id': 'dc_05', 'region_id': 'region_id_0007', 'pod_id': 'pod_id_0007', }, 'resource': 'wim-endpoints', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(update_params[key])) else: self.assertEqual(res_data[0].get(key), update_params[key])
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'nw_resource_kind': 5, 'type': 3, 'device_type': 1, 'redundant_configuration_flg': '1', 'type_detail': 2, 'threshold': 60, } request_params = { 'body': update_params, 'query': {}, 'resource': 'thresholds', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': { 'nw_resource_kind': 5, 'type': 3, 'device_type': 1, 'redundant_configuration_flg': '1', 'type_detail': 2, }, 'resource': 'thresholds', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: self.assertEqual(res_data[0].get(key), update_params[key])
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'dc_id': 'dc103', 'ce01_ip_address': '12.0.0.1', 'ce02_ip_address': '12.0.0.2', 'network_address': '12.0.0.0', 'netmask': 25, 'status': 2, 'group_id': 'group001', } request_params = { 'body': update_params, 'query': {}, 'resource': 'dc-segment', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': {}, 'resource': 'dc-segment', 'method': 'GET', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(update_params[key])) else: self.assertEqual(res_data[0].get(key), update_params[key])
def test_insert_api(self): insert_params = { 'create_id': 'test_create_id-0ac6cb428b23', 'update_id': 'test_update_id-0ac6cb428b23', 'delete_flg': 0, 'subnet_id': '12345', } request_params = { 'body': insert_params, 'query': {}, 'resource': 'pnf-vlan', 'method': 'POST', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertTrue('ID' in res_data) # Assertion(check select) request_params = { 'query': { 'delete_flg': 0, 'subnet_id': '12345', }, 'resource': 'pnf-vlan', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in insert_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(insert_params[key])) else: self.assertEqual(res_data[0].get(key), insert_params[key])
def test_select_api_sel_id(self): request_params = { 'request_id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'resource': 'global-ip-addresses', 'method': 'GET', 'id': [ID1] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Check to get number self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) # Check the contents of the data self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['create_date'], '2016-12-31 23:59:59') self.assertEqual(res_data[0]['update_id'], 'test_update_id-0ac6cb428b23') self.assertEqual(res_data[0]['update_date'], '2016-12-31 23:59:59') self.assertEqual(res_data[0]['delete_flg'], '0') self.assertEqual(res_data[0]['ID'], ID1) self.assertEqual(res_data[0]['global_ip'], '10.50.60.50') self.assertEqual(res_data[0].get('extension_info', ''), '') self.assertEqual(res_data[0]['status'], 1) self.assertEqual(res_data[0]['node_id'], 'node_id-11111111111') self.assertEqual(res_data[0]['tenant_name'], 'tenant_name001')
def test_delete_api(self): request_params = { 'body': {}, 'query': {}, 'resource': 'appliances', 'method': 'DELETE', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) con, cur = self.connect_db() cur.execute("SELECT ID FROM NAL_APL_MNG WHERE ID = %s", [ID]) self.assertEqual(cur.fetchall(), []) self.cut_db(con, cur)
def test_select_api(self): request_params = { 'query': { 'delete_flg': '0', 'ID': ID }, 'resource': 'tenants', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['delete_flg'], '0') self.assertEqual(res_data[0]['tenant_name'], 'tenant_id-dd7e-0ac6cb428b23') self.assertEqual(res_data[0].get('extension_info', ''), '') self.assertEqual(res_data[0]['IaaS_region_id'], 'IaaS_region_id001') self.assertEqual(res_data[0]['IaaS_tenant_id'], 'IaaS_tenant_id002') tenant_info = json.loads(res_data[0]['tenant_info']) self.assertEqual(tenant_info.get('pod_id'), 'pod_id1234567890') self.assertEqual(tenant_info.get('msa_customer_name'), 'name001') self.assertEqual(tenant_info.get('msa_customer_ID'), 10)
def test_select_api(self): request_params = { 'query': { 'delete_flg': '0', 'ID': ID }, 'resource': 'appliances', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertEqual(res_data[0]['ID'], ID) self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['delete_flg'], '0') self.assertEqual(res_data[0]['node_id'], 'node_id-dd7e-0ac6cb428b23') self.assertEqual(res_data[0].get('extension_info', ''), '') for key in extension_info: self.assertEqual(res_data[0].get(key), extension_info[key])
def test_update_api_err_notfound(self): update_params = { 'update_id': 'test_update_id-12', 'global_ip': '10.50.60.52', 'status': "", 'tenant_name': 'tenant_id-ad4c-4cc6ea276a55', 'node_id': 'node_id-ad4c-4cc6ea276a55' } request_params = { 'request_id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'body': update_params, 'query': {}, 'resource': 'global-ip-addresses', 'method': 'PUT', 'id': [0] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '404 NotFound') self.assertEqual(res_data, 'An object with the specified identifier was not found.')
def test_delete_api(self): request_params = { 'request_id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'body': {}, 'query': {}, 'resource': 'global-ip-addresses', 'method': 'DELETE', 'id': [ID1] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) con, cur = self.connect_db() cur.execute("SELECT ID FROM NAL_GLOBAL_IP_MNG " + "WHERE ID = %s", [ID1]) self.assertEqual(cur.fetchall(), []) self.cut_db(con, cur)
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'port_id': '888888', 'delete_flg': 1, } request_params = { 'body': update_params, 'query': {}, 'resource': 'pnf-vlan', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': { 'delete_flg': 1, 'port_id': '888888', }, 'resource': 'pnf-vlan', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: if key == 'delete_flg': self.assertEqual(res_data[0].get(key), str(update_params[key])) else: self.assertEqual(res_data[0].get(key), update_params[key])
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'pod_id': 'pod_id-ad4c-4cc6ea276a55', 'weight': 10, 'region_id': 'regionThree', } request_params = { 'body': update_params, 'query': {}, 'resource': 'pods', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': {}, 'resource': 'pods', 'method': 'GET', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertEqual(res_data[0]['update_id'], 'test_update_id-0ac6cb428b23') self.assertEqual(res_data[0]['delete_flg'], '0') self.assertEqual(res_data[0]['pod_id'], 'pod_id-ad4c-4cc6ea276a55') self.assertEqual(res_data[0].get('extension_info', ''), '') self.assertEqual(res_data[0]['weight'], 10) self.assertEqual(res_data[0]['region_id'], 'regionThree')
def test_update_api(self): update_params = { 'update_id': 'test_update_id-0ac6cb428b23', 'tenant_id': 'tenant_id-ad4c-4cc6ea276a55', 'node_id': 'node_id-bb6d-6bb9bd380a11', 'apl_type': 2, 'node_name': 'node_name001', } request_params = { 'body': update_params, 'query': {}, 'resource': 'appliances', 'method': 'PUT', 'id': [ID] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(res_data, True) # Assertion(check select) request_params = { 'query': { 'node_id': 'node_id-bb6d-6bb9bd380a11', }, 'resource': 'appliances', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) for key in update_params: self.assertEqual(res_data[0].get(key), update_params[key])
def test_select_api(self): request_params = { 'query': { 'delete_flg': '0', 'ID': ID }, 'resource': 'vlans', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertEqual(res_data[0]['ID'], ID) self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['delete_flg'], '0') self.assertEqual(res_data[0]['network_id'], 'network_id-dd7e-0ac6cb428b23') self.assertEqual(res_data[0].get('extension_info', ''), '') self.assertEqual(res_data[0]['tenant_name'], extension_info['tenant_name']) self.assertEqual(res_data[0]['pod_id'], extension_info['pod_id']) self.assertEqual(res_data[0]['tenant_id'], extension_info['tenant_id']) self.assertEqual(res_data[0]['IaaS_region_id'], extension_info['IaaS_region_id']) self.assertEqual(res_data[0]['IaaS_tenant_id'], extension_info['IaaS_tenant_id']) self.assertEqual(res_data[0]['IaaS_network_id'], extension_info['IaaS_network_id']) self.assertEqual(res_data[0]['IaaS_network_type'], extension_info['IaaS_network_type']) self.assertEqual(res_data[0]['IaaS_segmentation_id'], extension_info['IaaS_segmentation_id']) self.assertEqual(res_data[0]['vlan_id'], extension_info['vlan_id']) self.assertEqual(res_data[0]['vxlangw_pod_id'], extension_info['vxlangw_pod_id']) self.assertEqual(res_data[0]['rule_id'], extension_info['rule_id']) assert_info = json.loads(extension_info['nal_vlan_info']) nal_vlan_info = json.loads(res_data[0]['nal_vlan_info']) for key in assert_info: self.assertEqual(nal_vlan_info.get(key), assert_info[key])
def test_select_api(self): request_params = { 'query': { 'delete_flg': '0', 'ID': ID }, 'resource': 'pnf-vlan', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Assertion self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 1) self.assertEqual(res_data[0]['ID'], ID) self.assertEqual(res_data[0]['create_id'], 'test_create_id-0ac6cb428b23') self.assertEqual(res_data[0]['update_id'], 'test_update_id-0ac6cb428b23') self.assertEqual(res_data[0]['create_date'], '2016-12-31 23:59:59') self.assertEqual(res_data[0]['update_date'], '2016-12-31 23:59:59') self.assertEqual(res_data[0]['delete_flg'], '0') self.assertEqual(res_data[0].get('extension_info', ''), '') self.assertEqual(res_data[0]['pod_id'], extension_info['pod_id']) self.assertEqual(res_data[0]['vlan_id'], extension_info['vlan_id']) self.assertEqual(res_data[0]['network_address'], extension_info['network_address']) self.assertEqual(res_data[0]['netmask'], extension_info['netmask']) self.assertEqual(res_data[0]['status'], extension_info['status']) self.assertEqual(res_data[0]['tenant_name'], extension_info['tenant_name']) self.assertEqual(res_data[0]['network_id'], extension_info['network_id']) self.assertEqual(res_data[0]['subnet_id'], extension_info['subnet_id']) self.assertEqual(res_data[0]['port_id'], extension_info['port_id']) self.assertEqual(res_data[0]['rule_id'], extension_info['rule_id']) for key in extension_info: self.assertEqual(res_data[0].get(key), extension_info[key])
def test_select_api_sel_all(self): request_params = { 'request_id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'resource': 'global-ip-addresses', 'method': 'GET', 'id': [] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) # Check to get number self.assertEqual(status, '200 OK') self.assertGreaterEqual(len(res_data), 1)
def test_select_api_err_notfound(self): request_params = { 'request_id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'body': {}, 'query': {}, 'resource': 'global-ip-addresses', 'method': 'GET', 'id': [0] } res = router.Router().routing(request_params) status = res['status'] res_data = res['message'].decode('utf-8') res_data = json.loads(res_data) self.assertEqual(status, '200 OK') self.assertEqual(len(res_data), 0)