def factory_org_service(org_info: dict = TestOrgInfo.org1, org_type_info: dict = TestOrgTypeInfo.test_type, org_status_info: dict = TestOrgStatusInfo.test_status, payment_type_info: dict = TestPaymentTypeInfo.test_type): """Produce a templated org service.""" org_model = factory_org_model(org_info=org_info, org_type_info=org_type_info, org_status_info=org_status_info, payment_type_info=payment_type_info) org_service = OrgService(org_model) return org_service
def factory_org_service(org_info: dict = TestOrgInfo.org1, org_type_info: dict = None, org_status_info: dict = None, bcol_info: dict = TestBCOLInfo.bcol1): """Produce a templated org service.""" org_model = factory_org_model(org_info=org_info, org_type_info=org_type_info, org_status_info=org_status_info, bcol_info=bcol_info) org_service = OrgService(org_model) return org_service
def factory_org_service(name): """Produce a templated org model.""" org_type = OrgTypeModel(code='TEST', desc='Test') org_type.save() org_status = OrgStatusModel(code='TEST', desc='Test') org_status.save() preferred_payment = PaymentTypeModel(code='TEST', desc='Test') preferred_payment.save() org = OrgModel(name=name) org.org_type = org_type org.org_status = org_status org.preferred_payment = preferred_payment org.save() org_service = OrgService(org) return org_service
def patch(org_id): """Patch an account.""" request_json = request.get_json() try: org = OrgService(OrgModel.find_by_org_id(org_id)) if org: # set default patch action to updating status action action = request_json.get('action', PatchActions.UPDATE_STATUS.value) response, status = org.patch_org( action, request_json), http_status.HTTP_200_OK else: response, status = {'message': 'The requested organization could not be found.'}, \ http_status.HTTP_404_NOT_FOUND except BusinessException as exception: response, status = { 'code': exception.code, 'message': exception.message }, exception.status_code return response, status
def factory_org_service(session, name): """Produce a templated org service.""" org_type = OrgTypeModel(code='TEST', desc='Test') session.add(org_type) session.commit() org_status = OrgStatusModel(code='TEST', desc='Test') session.add(org_status) session.commit() preferred_payment = PaymentTypeModel(code='TEST', desc='Test') session.add(preferred_payment) session.commit() org_model = OrgModel(name=name) org_model.org_type = org_type org_model.org_status = org_status org_model.preferred_payment = preferred_payment org_model.save() org = OrgService(org_model) return org