def test_insert_owner(self): post_data = { "first_name": "Test first name", "last_name": "Test last name", "email": "Test email", "phone": "Test phone", "institution_uuid": "224fe496-5023-49e6-8953-19d5b1331333", "uuid": "53eee88a-aaa4-4d7b-86a4-4124e3a9d99d" } response = self.client_stub.post("/api/v1/owner/add", post_data) expected_data = { "account_id": None, "first_name": post_data["first_name"], "last_name": post_data["last_name"], "email": post_data["email"], "phone": post_data["phone"], "institution": { "name": "GRNET", "address": "Mesogeon av.", "country": "GREECE", "department": "Admin", "uuid": "224fe496-5023-49e6-8953-19d5b1331333" }, "uuid": post_data["uuid"] } expected_response = helper.get_response_info(strings.SERVICE_OWNER_INSERTED, expected_data, status=strings.CREATED_201) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_edit_owner(self): post_data = { "first_name": "Test first name", "last_name": "Test last name", "email": "Test email", "phone": "Test phone", "institution_uuid": "224fe496-5023-49e6-8953-19d5b1331333", "uuid": "a9976cd2-14e4-47b7-9353-7e9faba2f200" } response = self.client_stub.post("/api/v1/owner/edit", post_data) expected_data = { "account_id": None, "first_name": post_data["first_name"], "last_name": post_data["last_name"], "email": post_data["email"], "phone": post_data["phone"], "institution": { "name": "GRNET", "address": "Mesogeon av.", "country": "GREECE", "department": "Admin", "uuid": "224fe496-5023-49e6-8953-19d5b1331333" }, "uuid": post_data["uuid"] } expected_response = helper.get_response_info(strings.SERVICE_OWNER_UPDATED, expected_data, status=strings.UPDATED_202) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_service_owner(self): response_name = self.client_stub.get('/api/v1/portfolio/services/B2SAFE/service_owner') data = {"first_name": "Claudio", "last_name": "Cacciari", "uuid": "a9976cd2-14e4-47b7-9353-7e9faba2f200", "email": "*****@*****.**", "phone": "000", "institution": {"department": "Admin", "country": "ITALY", "address": "A", "uuid": "df3ab1f3-08d3-408a-bf00-532a41ccffa4", "name": "CINECA"}, "account_id": None} expected_response = helper.get_response_info(strings.SERVICE_OWNER_INFORMATION, data) self.assertJSONEqual(json.dumps(expected_response), response_name.content)
def test_insert_service_details_component(self): post_data = { "service_id": "B2SAFE", "service_version": "3.0", "component_implementation_details_uuid": "309ffba9-dc3f-45c5-8a2e-150cd2e62c92" } response = self.client_stub.post("/api/v1/component/service_details_component_implementation_details/add", post_data) expected_data = { "service_uuid": post_data["service_id"], "service_details_version": post_data["service_version"], "service_component_implementation_detail_uuid": post_data["component_implementation_details_uuid"] } expected_response = helper.get_response_info(strings.SERVICE_DETAILS_COMPONENT_INSERTED, expected_data, status=strings.CREATED_201) self.assertJSONEqual(json.dumps(expected_response), response.content)
def get_institution_all(request): query = request.GET.get('search') if query is not None: query = query.lower() institutions = [ i.as_json() for i in models.Institution.objects.all() if (query == None or query == "") or query in i.name.lower() ] response = helper.get_response_info(strings.SERVICE_OWNER_INFORMATION, institutions) return JsonResponse(response, status=int(response["status"][:3]))
def get_contact_information_all(request): query = request.GET.get('search') if query is not None: query = query.lower() owners = [ so.as_json() for so in models.ContactInformation.objects.all() if (query == None or query == "") or ( so.first_name is not None and query in so.first_name.lower()) or ( so.last_name is not None and query in so.last_name.lower()) ] response = helper.get_response_info(strings.SERVICE_OWNER_INFORMATION, owners) return JsonResponse(response, status=int(response["status"][:3]))
def test_insert_service_component_implementation_details_with_uuid(self): post_data = { "version": "0.1.2", "configuration_parameters": "<xml>Test configuration</xml>", "uuid": "56601d76-c1e2-488c-a812-dba8e5508c2e", "component_uuid": "af2f812b-eda6-497a-9d22-534f885b7034", "component_implementation_uuid": "d01dcee5-eb04-4147-9bb0-54ed81567494" } response = self.client_stub.post("/api/v1/component/service_component_implementation_detail/add", post_data) expected_data = { "uuid": post_data["uuid"], "version": post_data["version"], "configuration_parameters": post_data["configuration_parameters"] } expected_response = helper.get_response_info(strings.SERVICE_COMPONENT_IMPLEMENTATION_DETAILS_INSERTED, expected_data, status=strings.CREATED_201) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_service_owner_institution(self): response_name = self.client_stub.get('/api/v1/portfolio/services/B2SAFE/service_owner/Claudio_Cacciari/institution') response_uuid = self.client_stub.get('/api/v1/portfolio/services/88b35b0d-adc2-4a2e-b5fc-cae2d6f5456a/service_owner/a9976cd2-14e4-47b7-9353-7e9faba2f200/institution') data = { "department": "Admin", "country": "ITALY", "address": "A", "uuid": "df3ab1f3-08d3-408a-bf00-532a41ccffa4", "name": "CINECA" } expected_response = helper.get_response_info(strings.SERVICE_OWNER_INSTITUTION, data) self.assertJSONEqual(json.dumps(expected_response), response_name.content) self.assertJSONEqual(json.dumps(expected_response), response_uuid.content)
def test_edit_service_component_implementation_details(self): post_data = { "version": "0.1.2", "configuration_parameters": "<xml>Test configuration</xml>", "uuid": "309ffba9-dc3f-45c5-8a2e-150cd2e62c92", "component_uuid": "af2f812b-eda6-497a-9d22-534f885b7034", "component_implementation_uuid": "bac1cb25-f24e-4cea-a2e8-d94b27a2e169" } expected_data = { "uuid": post_data["uuid"], "version": post_data["version"], "configuration_parameters": post_data["configuration_parameters"] } response = self.client_stub.post("/api/v1/component/service_component_implementation_detail/edit", post_data) expected_response = helper.get_response_info(strings.SERVICE_COMPONENT_IMPLEMENTATION_DETAILS_UPDATED, expected_data, status=strings.UPDATED_202) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_insert_service_component_with_uuid(self): post_data = { "name": "Test name", "description": "Test description", "uuid": "56601d76-c1e2-488c-a812-dba8e5508c2e" } response = self.client_stub.post("/api/v1/component/add", post_data) expected_data = { "uuid": post_data["uuid"], "name": post_data["name"], "description": post_data["description"], "component_implementations_list": { "count": 0, "component_implementations": [] } } expected_response = helper.get_response_info(strings.SERVICE_COMPONENT_INSERTED, expected_data, status=strings.CREATED_201) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_insert_institution(self): post_data = { "name": "Test name", "address": "Test address", "country": "Test country", "department": "Test department", "uuid": "72eee88a-aaa4-4d7b-86a4-4124e3a9d99d" } response = self.client_stub.post("/api/v1/owner/institution/add", post_data) expected_data = { "name": post_data["name"], "address": post_data["address"], "country": post_data["country"], "department": post_data["department"], "uuid": post_data["uuid"] } expected_response = helper.get_response_info(strings.INSTITUTION_INSERTED, expected_data, status=strings.CREATED_201) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_edit_service_component_implementation(self): post_data = { "name": "Test name", "description": "Test description", "component_uuid": "af2f812b-eda6-497a-9d22-534f885b7034", "uuid": "5e27aa64-4668-464c-96c7-fbe5b4871219", } expected_data = { "uuid": post_data["uuid"], "name": post_data["name"], "description": post_data["description"], "component_implementation_details_list": { "count": 0, "component_implementation_details": [] } } response = self.client_stub.post("/api/v1/component/service_component_implementation/edit", post_data) expected_response = helper.get_response_info(strings.SERVICE_COMPONENT_IMPLEMENTATION_UPDATED, expected_data, status=strings.UPDATED_202) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_edit_institution(self): post_data = { "name": "Test name", "address": "Test address", "country": "Test country", "department": "Test department", "uuid": "56da9c1f-1842-4158-8dfd-e2d2d01ace08" } response = self.client_stub.post("/api/v1/owner/institution/edit", post_data) expected_data = { "name": post_data["name"], "address": post_data["address"], "country": post_data["country"], "department": post_data["department"], "uuid": post_data["uuid"] } expected_response = helper.get_response_info(strings.INSTITUTION_UPDATED, expected_data, status=strings.UPDATED_202) self.assertJSONEqual(json.dumps(expected_response), response.content)
def get_institution(request, institution_uuid): response = {} prog = re.compile( "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" ) result = prog.match(institution_uuid) institution = None try: institution = models.Institution.objects.get(id=institution_uuid) except models.ServiceOwner.DoesNotExist: response = helper.get_error_response(strings.INSTITUTION_NOT_FOUND) except ValueError as v: if str(v) == "badly formed hexadecimal UUID string": response = helper.get_error_response(strings.INVALID_UUID) response = helper.get_response_info(strings.SERVICE_OWNER_INFORMATION, institution.as_json()) return JsonResponse(response, status=int(response["status"][:3]))
def test_insert_contact(self): post_data = { "first_name": "Test first name", "last_name": "Test last name", "email": "Test email", "phone": "Test phone", "url": "Test url", "uuid": "73eee88a-aaa4-4d7b-86a4-4124e3a9d99d" } response = self.client_stub.post("/api/v1/owner/contact_information/add", post_data) expected_data = { "first_name": post_data["first_name"], "last_name": post_data["last_name"], "email": post_data["email"], "phone": post_data["phone"], "uuid": post_data["uuid"] } expected_response = helper.get_response_info(strings.CONTACT_INFORMATION_INSERTED, expected_data, status=strings.CREATED_201) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_edit_contact(self): post_data = { "first_name": "Test first name", "last_name": "Test last name", "email": "Test email", "phone": "Test phone", "url": "Test url", "uuid": "7166dfad-082b-4e81-bf86-cae10af12cfd" } response = self.client_stub.post("/api/v1/owner/contact_information/edit", post_data) expected_data = { "first_name": post_data["first_name"], "last_name": post_data["last_name"], "email": post_data["email"], "phone": post_data["phone"], "uuid": post_data["uuid"] } expected_response = helper.get_response_info(strings.CONTACT_INFORMATION_UPDATED, expected_data, status=strings.UPDATED_202) self.assertJSONEqual(json.dumps(expected_response), response.content)
def get_service_owner(request, service_name_or_uuid): """ Retrieves a the service owner """ response = {} prog = re.compile( "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" ) result = prog.match(service_name_or_uuid) service, parsed_name, uuid = None, None, None if result is None: # parsed_name = service_name_or_uuid.replace("_", " ").strip() parsed_name = service_name_or_uuid.strip() else: uuid = service_name_or_uuid try: if result is None: service = service_models.Service.objects.get(name=parsed_name) else: service = service_models.Service.objects.get(id=uuid) except service_models.Service.DoesNotExist: response = helper.get_error_response(strings.SERVICE_NOT_FOUND) except ValueError as v: if str(v) == "badly formed hexadecimal UUID string": response = helper.get_error_response(strings.INVALID_UUID) if service is not None: response = helper.get_response_info(strings.SERVICE_OWNER_INFORMATION, service.get_service_owners()) return JsonResponse(response, status=int(response["status"][:3]))
def insert_contact_information(request): """ Inserts a contact information object """ op_type = helper.get_last_url_part(request) uuid, contact_information = None, None params = helper.get_request_data(request) prog = re.compile( "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" ) condition = False if "uuid" in params: uuid = params.get("uuid") result = prog.match(uuid) if result is None: return JsonResponse(helper.get_error_response( strings.INVALID_UUID, status=strings.REJECTED_406), status=406) try: contact_information = models.ContactInformation.objects.get( id=uuid) if op_type == "add": return JsonResponse(helper.get_error_response( strings.CONTACT_INFORMATION_UUID_EXISTS, status=strings.CONFLICT_409), status=409) except models.ContactInformation.DoesNotExist: contact_information = models.ContactInformation() if op_type == "edit": return JsonResponse(helper.get_error_response( strings.CONTACT_INFORMATION_NOT_FOUND, status=strings.NOT_FOUND_404), status=404) elif op_type == "edit": return JsonResponse(helper.get_error_response( strings.SERVICE_CONTACT_INFORMATION_UUID_NOT_PROVIDED, status=strings.REJECTED_406), status=406) elif op_type == "add": contact_information = models.ContactInformation() # if ("email" not in params) and ("url" not in params): # return JsonResponse(helper.get_error_response(strings.OWNER_URL_OR_EMAIL_NOT_PROVIDED, status=strings.REJECTED_406)) email, url = None, None if "email" in params: email = params["email"] if "url" in params: url = params["url"] if (email is None or email == "") and (url is None or url == ""): return JsonResponse( helper.get_error_response(strings.OWNER_URL_OR_EMAIL_NOT_PROVIDED, status=strings.REJECTED_406)) if "first_name" in params: first_name = params.get('first_name') # if first_name is None or len(first_name) == 0: # return JsonResponse(helper.get_error_response(strings.OWNER_FIRST_NAME_EMPTY, status=strings.REJECTED_406)) contact_information.first_name = first_name if "last_name" in params: last_name = params.get('last_name') # if last_name is None or len(last_name) == 0: # return JsonResponse(helper.get_error_response(strings.OWNER_LAST_NAME_EMPTY, status=strings.REJECTED_406)) contact_information.last_name = last_name # if "email" in params: # email = params.get('email') # if email is None or len(email) == 0: # return JsonResponse(helper.get_error_response(strings.OWNER_EMAIL_EMPTY, status=strings.REJECTED_406), # status=406) contact_information.email = email if "phone" in params: phone = params.get('phone') # if phone is None or len(phone) == 0: # return JsonResponse(helper.get_error_response(strings.OWNER_PHONE_EMPTY, status=strings.REJECTED_406)) contact_information.phone = phone # if "url" in params: # url = params.get('url') # if url is None or len(url) == 0: # return JsonResponse(helper.get_error_response(strings.OWNER_URL_EMPTY, status=strings.REJECTED_406), # status=406) contact_information.url = url if uuid is not None: contact_information.id = uuid try: contact_information.save() except IntegrityError: return JsonResponse(helper.get_error_response( strings.CONTACT_INFORMATION_EXISTS, status=strings.REJECTED_406), status=406) data = contact_information.as_json() msg = strings.CONTACT_INFORMATION_INSERTED if op_type == "add" else strings.CONTACT_INFORMATION_UPDATED status = strings.CREATED_201 if op_type == "add" else strings.UPDATED_202 response = helper.get_response_info(msg, data, status=status) return JsonResponse(response, status=int(response["status"][:3]))
def insert_institution(request): """ Inserts an institution object :param request: :return: """ op_type = helper.get_last_url_part(request) params = helper.get_request_data(request) prog = re.compile( "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" ) uuid, name, institution = None, None, None if "name" not in params and op_type == "add": return JsonResponse( helper.get_error_response(strings.INSTITUTION_NAME_NOT_PROVIDED, status=strings.REJECTED_406), status=406) elif "name" in params: name = params.get('name') if name is None or len(name) == 0: return JsonResponse(helper.get_error_response( strings.INSTITUTION_NAME_EMPTY, status=strings.REJECTED_406), status=406) elif op_type == "edit": name = None if "uuid" in params: uuid = params.get("uuid") result = prog.match(uuid) if result is None: return JsonResponse(helper.get_error_response( strings.INVALID_UUID, status=strings.REJECTED_406), status=406) try: institution = models.Institution.objects.get(id=uuid) if op_type == "add": return JsonResponse(helper.get_error_response( strings.INSTITUTION_UUID_EXISTS, status=strings.CONFLICT_409), status=409) except models.Institution.DoesNotExist: institution = models.Institution() if op_type == "edit": return JsonResponse(helper.get_error_response( strings.INSTITUTION_NOT_FOUND, status=strings.NOT_FOUND_404), status=404) elif op_type == "edit": return JsonResponse( helper.get_error_response(strings.INSTITUTION_UUID_NOT_PROVIDED, status=strings.REJECTED_406), status=406) elif op_type == "add": institution = models.Institution() if name is not None: institution.name = name if "address" in params: institution.address = params.get('address') if "country" in params: institution.country = params.get('country') if "department" in params: institution.department = params.get('department') if uuid is not None: institution.id = uuid try: institution.save() except IntegrityError: return JsonResponse(helper.get_error_response( strings.INSTITUTION_NAME_EXISTS, status=strings.REJECTED_406), status=406) data = institution.as_json() msg = strings.INSTITUTION_INSERTED if op_type == "add" else strings.INSTITUTION_UPDATED status = strings.CREATED_201 if op_type == "add" else strings.UPDATED_202 response = helper.get_response_info(msg, data, status=status) return JsonResponse(response, status=int(response["status"][:3]))
def test_get_service_components_empty(self): response = self.client_stub.get('/api/v1/portfolio/services/583ec8f2-9ef6-4e51-89bd-9af7f5fcea9c/service_details/1.0/service_components/') data = {"service_components_list": {"count": 0, "service_components": []}} expected_response = helper.get_response_info(strings.SERVICE_COMPONENTS_INFORMATION, data) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_get_service_components(self): response = self.client_stub.get('/api/v1/portfolio/services/B2SAFE/service_details/3.0/service_components') data = {"service_components_list": {"count": 2, "service_components": [{"description": "zdero", "component_implementation_link": {"related": {"href": "http://agora-dev.aris.grnet.gr/api/v1/portfolio/services/B2SAFE/service_details/3.0/service_components/af2f812b-eda6-497a-9d22-534f885b7034/service_component_implementations", "meta": {"desc": "Link to the concrete service component implementations."}}}, "uuid": "af2f812b-eda6-497a-9d22-534f885b7034", "name": "Komponenta 1"}, {"description": "Python/Django", "component_implementation_link": {"related": {"href": "http://agora-dev.aris.grnet.gr/api/v1/portfolio/services/B2SAFE/service_details/3.0/service_components/3fa0bece-3e12-40ca-8345-1af82bf5f471/service_component_implementations", "meta": {"desc": "Link to the concrete service component implementations."}}}, "uuid": "3fa0bece-3e12-40ca-8345-1af82bf5f471", "name": "Application framework"}]}} expected_response = helper.get_response_info(strings.SERVICE_COMPONENTS_INFORMATION, data) self.assertJSONEqual(json.dumps(expected_response), response.content)
def test_get_service_component_implementations_detail(self): response = self.client_stub.get('/api/v1/portfolio/services/B2SAFE/service_details/3.0/service_components/af2f812b-eda6-497a-9d22-534f885b7034/service_component_implementations/d01dcee5-eb04-4147-9bb0-54ed81567494/service_component_implementation_detail') data = {"service_component_implementation_details_list": {"count": 1, "service_component_implementation_details": [{"version": "4", "uuid": "a1b4569c-b7eb-4881-9f93-2e37ee662c28", "configuration_parameters": "d"}]}} expected_response = helper.get_response_info(strings.SERVICE_COMPONENT_IMPLEMENTATION_DETAILS, data) self.assertJSONEqual(json.dumps(expected_response), response.content)
def insert_service_owner(request): """ Inserts a service owner object """ op_type = helper.get_last_url_part(request) params = helper.get_request_data(request) prog = re.compile( "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" ) if "email" not in params: return JsonResponse( helper.get_error_response(strings.SERVICE_OWNER_EMAIL_NOT_PROVIDED, status=strings.REJECTED_406)) institution, institution_uuid, service_owner, uuid = None, None, None, None # if "institution_uuid" not in params: # return JsonResponse(helper.get_error_response(strings.INSTITUTION_UUID_NOT_PROVIDED, # status=strings.REJECTED_406), status=406) if "institution_uuid" in params: institution_uuid = params.get('institution_uuid') result = prog.match(institution_uuid) if result is None: return JsonResponse(helper.get_error_response( strings.INVALID_UUID, status=strings.REJECTED_406), status=406) try: institution = models.Institution.objects.get(id=institution_uuid) except models.Institution.DoesNotExist: return JsonResponse(helper.get_error_response( strings.INSTITUTION_NOT_FOUND, status=strings.NOT_FOUND_404), status=404) if "uuid" in params: uuid = params.get("uuid") result = prog.match(uuid) if result is None: return JsonResponse(helper.get_error_response( strings.INVALID_UUID, status=strings.REJECTED_406), status=406) try: service_owner = models.ServiceOwner.objects.get(id=uuid) if op_type == "add": return JsonResponse(helper.get_error_response( strings.SERVICE_OWNER_UUID_EXISTS, status=strings.CONFLICT_409), status=409) except models.ServiceOwner.DoesNotExist: service_owner = models.ServiceOwner() if op_type == "edit": return JsonResponse(helper.get_error_response( strings.SERVICE_OWNER_NOT_FOUND, status=strings.NOT_FOUND_404), status=404) elif op_type == "edit": return JsonResponse(helper.get_error_response( strings.SERVICE_OWNER_UUID_NOT_PROVIDED, status=strings.REJECTED_406), status=406) elif op_type == "add": service_owner = models.ServiceOwner() if "first_name" in params: first_name = params.get('first_name') # if first_name is None or len(first_name) == 0: # return JsonResponse(helper.get_error_response(strings.OWNER_FIRST_NAME_EMPTY, status=strings.REJECTED_406)) service_owner.first_name = first_name if "last_name" in params: last_name = params.get('last_name') # if last_name is None or len(last_name) == 0: # return JsonResponse(helper.get_error_response(strings.OWNER_LAST_NAME_EMPTY, status=strings.REJECTED_406)) service_owner.last_name = last_name if "email" in params: email = params.get('email') if email is None or len(email) == 0: return JsonResponse(helper.get_error_response( strings.OWNER_EMAIL_EMPTY, status=strings.REJECTED_406), status=406) service_owner.email = email if "phone" in params: phone = params.get('phone') # if phone is None or len(phone) == 0: # return JsonResponse(helper.get_error_response(strings.OWNER_PHONE_EMPTY, status=strings.REJECTED_406)) service_owner.phone = phone service_owner.id_service_owner = institution if uuid is not None: service_owner.id = uuid try: service_owner.save() except IntegrityError: return JsonResponse(helper.get_error_response( strings.SERVICE_OWNER_EMAIL_EXISTS, status=strings.REJECTED_406), status=406) data = service_owner.as_json() msg = strings.SERVICE_OWNER_INSERTED if op_type == "add" else strings.SERVICE_OWNER_UPDATED status = strings.CREATED_201 if op_type == "add" else strings.UPDATED_202 response = helper.get_response_info(msg, data, status=status) return JsonResponse(response, status=int(response["status"][:3]))
def get_service_owner_institution(request, service_name_or_uuid, service_owner): """ Retrieves the institution of the owner """ response = {} service, owner, parsed_name, uuid, owner_name, owner_uuid, owner_email = None, None, None, None, None, None, None prog = re.compile( "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" ) result = prog.match(service_name_or_uuid) owner_match = prog.match(service_owner) if result is None: # parsed_name = service_name_or_uuid.replace("_", " ").strip() parsed_name = service_name_or_uuid.strip() else: uuid = service_name_or_uuid if owner_match is None: if '@' not in service_owner: owner_name = service_owner.split("_") else: owner_email = service_owner else: owner_uuid = service_owner try: if result is None: service = service_models.Service.objects.get(name=parsed_name) else: service = service_models.Service.objects.get(id=uuid) if owner_match is None: if '@' not in service_owner: owner = service_models.ServiceOwner.objects.get( first_name=owner_name[0], last_name=owner_name[1]) else: owner = service_models.ServiceOwner.objects.get( email=owner_email) else: owner = service_models.ServiceOwner.objects.get(id=owner_uuid) except models.ServiceOwner.DoesNotExist: owner = None response = helper.get_error_response(strings.OWNER_NOT_FOUND) except service_models.Service.DoesNotExist: service = None response = helper.get_error_response(strings.SERVICE_NOT_FOUND) except ValueError as v: if str(v) == "badly formed hexadecimal UUID string": response = helper.get_error_response(strings.INVALID_UUID) if service is not None and owner is not None: response = helper.get_response_info(strings.SERVICE_OWNER_INSTITUTION, owner.get_institution()) return JsonResponse(response, status=int(response["status"][:3]))
def test_get_service_component_implementations(self): response = self.client_stub.get('/api/v1/portfolio/services/B2SAFE/service_details/3.0/service_components/af2f812b-eda6-497a-9d22-534f885b7034/service_component_implementations') data = {"service_component_implementations_list": {"count": 2, "service_component_implementations": [{"component_implementation_details_link": {"related": {"href": "http://agora-dev.aris.grnet.gr/api/v1/portfolio/services/B2SAFE/service_details/3.0/service_components/af2f812b-eda6-497a-9d22-534f885b7034/service_component_implementations/d01dcee5-eb04-4147-9bb0-54ed81567494/service_component_implementation_detail", "meta": {"desc": "Link to the concrete service component implementation details."}}}, "description": "Nesto", "uuid": "d01dcee5-eb04-4147-9bb0-54ed81567494", "name": "Implementacija 2"}, {"component_implementation_details_link": {"related": {"href": "http://agora-dev.aris.grnet.gr/api/v1/portfolio/services/B2SAFE/service_details/3.0/service_components/af2f812b-eda6-497a-9d22-534f885b7034/service_component_implementations/bac1cb25-f24e-4cea-a2e8-d94b27a2e169/service_component_implementation_detail", "meta": {"desc": "Link to the concrete service component implementation details."}}}, "description": "asdfasd", "uuid": "bac1cb25-f24e-4cea-a2e8-d94b27a2e169", "name": "Implementacija 1"}]}} expected_response = helper.get_response_info(strings.SERVICE_COMPONENT_IMPLEMENTATIONS_INFORMATION, data) self.assertJSONEqual(json.dumps(expected_response), response.content)