def convert_service_entity_model_to_db_model(username, service): return ServiceDBModel( org_uuid=service.org_uuid, uuid=service.uuid, display_name=service.display_name, service_id=service.service_id, metadata_ipfs_hash=service.metadata_ipfs_hash, proto=service.proto, short_description=service.short_description, description=service.description, project_url=service.project_url, assets=service.assets, rating=service.rating, ranking=service.ranking, contributors=service.contributors, tags=service.tags, mpe_address=service.mpe_address, created_on=dt.utcnow(), groups=[ ServiceFactory.convert_service_group_entity_model_to_db_model( group) for group in service.groups ], service_state=ServiceFactory. convert_service_state_entity_model_to_db_model( username, service.service_state))
def test_get_list_of_service_pending_for_approval( self, post_request, validate_slack_signature, validate_slack_channel_id, validate_slack_user): validate_slack_channel_id.return_value = True validate_slack_user.return_value = True validate_slack_signature.return_value = True post_request.return_value.status_code = 200 post_request.return_value.text = "" self.tearDown() org_repo.add_organization( OrganizationDomainModel("test_org_uuid", "test_org_id", "org_dummy", "ORGANIZATION", "PUBLISHER", "description", "short_description", "https://test.io", [], {}, "ipfs_hash", "123456879", [], [], [], []), "dummy", OrganizationStatus.PUBLISHED.value) service_repo.add_item( ServiceDBModel(org_uuid="test_org_uuid", uuid="test_service_uuid_1", display_name="test_display_name_1", service_id="test_service_id_1", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, created_on=dt.utcnow())) service_repo.add_item( ServiceDBModel(org_uuid="test_org_uuid", uuid="test_service_uuid_2", display_name="test_display_name_2", service_id="test_service_id_2", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid_1", state=ServiceStatus.APPROVAL_PENDING.value, transaction_hash=None, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1001, org_uuid="test_org_uuid", service_uuid="test_service_uuid_2", state=ServiceStatus.APPROVAL_PENDING.value, transaction_hash=None, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) event = { "resource": "/services", "path": "/services", "httpMethod": "POST", "headers": { "Content-Type": "application/x-www-form-urlencoded", "Host": "mu1l28rgji.execute-api.us-east-1.amazonaws.com", "X-Slack-Request-Timestamp": "1585592248", "X-Slack-Signature": "v0=2f1e3b11bd3758d159971da4f0c2fe4569757a5ebb7991a48f84ee19cbfd7725" }, "queryStringParameters": None, "requestContext": {}, "body": urlencode({ "token": "HiVKf04RB8GV6bmaaBqx7nAr", "team_id": "T996H7VS8", "team_domain": "snet", "channel_id": "2QWW3E4R5RT6", "channel_name": "privategroup", "user_id": "UE8CNNEGZ", "user_name": "dummy", "command": "/list-orgs-for-approval", "response_url": "https://hooks.slack.com/commands", "trigger_id": "1026304454913.315221267892.794872083bae86aa00c776ba3bc74b30" }), "isBase64Encoded": False } response = get_list_of_service_pending_for_approval(event, context=None) assert (response["statusCode"] == 200)
def test_review_submission_for_service(self, slack_notification, email_notification, validate_slack_signature, validate_slack_channel_id, validate_slack_user): validate_slack_channel_id.return_value = True validate_slack_user.return_value = True validate_slack_signature.return_value = True self.tearDown() org_repo.add_organization( OrganizationDomainModel("test_org_uuid", "test_org_id", "org_dummy", "ORGANIZATION", "PUBLISHER", "description", "short_description", "https://test.io", [], {}, "ipfs_hash", "123456879", [], [], [], []), "dummy", OrganizationStatus.PUBLISHED.value) service_repo.add_item( ServiceDBModel(org_uuid="test_org_uuid", uuid="test_service_uuid_1", display_name="test_display_name_1", service_id="test_service_id_1", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid_1", state=ServiceStatus.APPROVAL_PENDING.value, transaction_hash=None, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) event = { "resource": "/submit", "path": "/submit", "httpMethod": "POST", "headers": { "Accept": "application/json,*/*", "Content-Type": "application/x-www-form-urlencoded", "X-Slack-Request-Timestamp": "1585737114", "X-Slack-Signature": "v0=5f52fbfa5a80733a0c7d9cad29dc69b452c402ad314e3409202a7b58f478461d" }, "body": urlencode({ "payload": json.dumps({ "type": "view_submission", "user": { "username": "******" }, "trigger_id": "1042957767015.315221267892.fc7b53b0ce0f2d82c63b75e8b8600718", "view": { "type": "modal", "blocks": [{ "type": "section", "block_id": "7Jh", "fields": [{ "type": "mrkdwn", "text": "*Organization Id:*\ntest_org_id", "verbatim": False }, { "type": "mrkdwn", "text": "*Service Id:*\ntest_service_id_1", "verbatim": False }, { "type": "mrkdwn", "text": "*Service Name:*\ntest_display_name_1", "verbatim": False }, { "type": "mrkdwn", "text": "*Approval Platform:*\n<http://dummy.com>\n", "verbatim": False }, { "type": "mrkdwn", "text": "*When:*\nMar10, 2020 (16 Days before)\n", "verbatim": False }] }], "state": { "values": { "approval_state": { "selection": { "type": "radio_buttons", "selected_option": { "text": { "type": "plain_text", "text": "Reject", "emoji": True }, "value": "REJECTED", "description": { "type": "plain_text", "text": "Description for option 2", "emoji": True } } } }, "review_comment": { "comment": { "type": "plain_text_input", "value": "service has missing proto files" } } } }, "title": { "type": "plain_text", "text": "Service For Approval", "emoji": True } }, "response_urls": [] }) }), "isBase64Encoded": False } response = slack_interaction_handler(event=event, context=None) assert (response["statusCode"] == 200)
def test_slack_interaction_handler_to_view_service_modal( self, slack_notification, email_notification, post_request, validate_slack_signature, validate_slack_channel_id, validate_slack_user): validate_slack_channel_id.return_value = True validate_slack_user.return_value = True validate_slack_signature.return_value = True post_request.return_value.status_code = 200 self.tearDown() org_repo.add_organization( OrganizationDomainModel("test_org_uuid", "test_org_id", "org_dummy", "ORGANIZATION", "PUBLISHER", "description", "short_description", "https://test.io", [], {}, "ipfs_hash", "123456879", [], [], [], []), "dummy", OrganizationStatus.PUBLISHED.value) service_repo.add_item( ServiceDBModel(org_uuid="test_org_uuid", uuid="test_service_uuid_1", display_name="test_display_name_1", service_id="test_service_id_1", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid_1", state=ServiceStatus.APPROVAL_PENDING.value, transaction_hash=None, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) event = { "resource": "/submit", "path": "/submit", "httpMethod": "POST", "headers": { "Accept": "application/json,*/*", "Content-Type": "application/x-www-form-urlencoded", "X-Slack-Request-Timestamp": "1585742597", "X-Slack-Signature": "v0=5096314f4b78b0b75366d8429a5195ea01c7e67f5618ee05f8e94a94953e05fd" }, "body": urlencode({ "payload": json.dumps({ "type": "block_actions", "team": { "id": "T996H7VS8", "domain": "snet" }, "user": { "username": "******" }, "trigger_id": "1028338009186.315221267892.83550c5f247eb73b0ad743511e8698a6", "channel": { "id": "Q2W3E4R5T6" }, "response_url": "https://hooks.slack.com/actions", "actions": [{ "action_id": "review", "block_id": "NJ0wG", "text": { "type": "plain_text", "text": "Review", "emoji": True }, "value": json.dumps({ "org_id": "test_org_id", "service_id": "test_service_id_1", "path": "/service" }), "style": "primary", "type": "button", "action_ts": "1585742597.398302" }] }) }), "isBase64Encoded": False } response = slack_interaction_handler(event=event, context=None) assert (response["statusCode"] == 200)
def test_save_service_attributes(self): org_repo.add_item( OrganizationDBModel( name="test_org", org_id="test_org_id", uuid="test_org_uuid", org_type="organization", description="that is the dummy org for testcases", short_description="that is the short description", url="https://dummy.url", contacts=[], assets={}, duns_no=12345678, origin="PUBLISHER_DAPP", groups=[], addresses=[], metadata_ipfs_uri="#dummyhashdummyhash")) new_org_members = [{ "username": "******", "address": "0x123" }, { "username": "******", "address": "0x234" }, { "username": "******", "address": "0x345" }] org_repo.add_all_items([ OrganizationMemberDBModel( username=member["username"], org_uuid="test_org_uuid", role=Role.MEMBER.value, address=member["address"], status=OrganizationMemberStatus.ACCEPTED.value, transaction_hash="0x123", invite_code=str(uuid4()), invited_on=dt.utcnow(), updated_on=dt.utcnow()) for member in new_org_members ]) service_repo.add_item( ServiceDBModel(org_uuid="test_org_uuid", uuid="test_service_uuid", display_name="test_display_name", service_id="test_service_id", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid", state=ServiceStatus.APPROVAL_PENDING.value, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) service_repo.add_item( ServiceGroupDBModel( row_id="1000", org_uuid="test_org_uuid", service_uuid="test_service_uuid", group_id="test_group_id", endpoints={ "https://dummydaemonendpoint.io": { "verfied": True } }, daemon_address=["0xq2w3e4rr5t6y7u8i9"], free_calls=10, free_call_signer_address="0xq2s3e4r5t6y7u8i9o0", created_on=dt.utcnow())) event = { "path": "/org/test_org_uuid/service", "requestContext": { "authorizer": { "claims": { "email": "*****@*****.**" } } }, "httpMethod": "PUT", "pathParameters": { "org_uuid": "test_org_uuid", "service_uuid": "test_service_uuid" }, "body": json.dumps({ "groups": [{ "group_name": "defaultGroup", "group_id": "l/hp6f1RXFPANeLWFZYwTB93Xi42S8NpZHfnceS6eUw=", "free_calls": 15, "free_call_signer_address": "0x7DF35C98f41F3Af0df1dc4c7F7D4C19a71Dd059F", "pricing": [{ "default": True, "price_model": "fixed_price", "price_in_cogs": 1 }], "endpoints": { "https://example-service-a.singularitynet.io:8010": { "valid": False }, "https://example-service-a.singularitynet.io:8013": { "valid": False }, "https://example-service-a.singularitynet.io:8011": { "valid": True } }, }] }) } response = save_service_attributes(event=event, context=None) assert (response["statusCode"] == 200) response_body = json.loads(response["body"]) assert (response_body["status"] == "success") assert (response_body["data"]["service_uuid"] == "test_service_uuid") assert (response_body["data"]["service_state"]["state"] == ServiceStatus.APPROVAL_PENDING.value) assert (response_body["data"]['groups'] == [{ 'group_id': 'l/hp6f1RXFPANeLWFZYwTB93Xi42S8NpZHfnceS6eUw=', 'group_name': 'defaultGroup', 'endpoints': { 'https://example-service-a.singularitynet.io:8010': { 'valid': False }, 'https://example-service-a.singularitynet.io:8013': { 'valid': False }, 'https://example-service-a.singularitynet.io:8011': { 'valid': True } }, 'test_endpoints': [], 'pricing': [{ 'default': True, 'price_model': 'fixed_price', 'price_in_cogs': 1 }], 'free_calls': 15, 'free_call_signer_address': '0x7DF35C98f41F3Af0df1dc4c7F7D4C19a71Dd059F', 'daemon_addresses': [] }])
def test_daemon_config_for_test_and_main_environment(self): org_repo.add_item( OrganizationDBModel( name="test_org", org_id="test_org_id", uuid="test_org_uuid", org_type="organization", description="that is the dummy org for testcases", short_description="that is the short description", url="https://dummy.url", contacts=[], assets={}, duns_no=12345678, origin="PUBLISHER_DAPP", groups=[], addresses=[], metadata_ipfs_uri="#dummyhashdummyhash")) new_org_members = [{ "username": "******", "address": "0x345" }] org_repo.add_all_items([ OrganizationMemberDBModel( username=member["username"], org_uuid="test_org_uuid", role=Role.MEMBER.value, address=member["address"], status=OrganizationMemberStatus.ACCEPTED.value, transaction_hash="0x123", invite_code=str(uuid4()), invited_on=dt.utcnow(), updated_on=dt.utcnow()) for member in new_org_members ]) org_repo.add_item( OrganizationStateDBModel(org_uuid="test_org_uuid", state="PUBLISHED", created_by="*****@*****.**", updated_by="*****@*****.**")) service_repo.add_item( ServiceDBModel( org_uuid="test_org_uuid", uuid="test_service_uuid", display_name="test_display_name", service_id="test_service_id", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, proto={ "proto_files": { "url": "https://ropsten-marketplace-service-assets.s3.amazonaws.com/test_org_uuid/services/test_service_uuid/assets/20200212111248_proto_files.zip" } }, contributors={"email_id": "*****@*****.**"}, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid", state=ServiceStatus.DRAFT.value, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) event = { "path": "/org/test_org_uuid/service/test_service_uuid/group_id/test_group_id/daemon/config", "requestContext": { "authorizer": { "claims": { "email": "*****@*****.**" } } }, "httpMethod": "GET", "pathParameters": { "org_uuid": "test_org_uuid", "service_uuid": "test_service_uuid", "group_id": "test_group_id" }, "queryStringParameters": { "network": EnvironmentType.MAIN.value } } response = get_daemon_config_for_current_network(event, "") assert (response["statusCode"] == 200) response_body = json.loads(response["body"]) assert (response_body["status"] == "success") assert (response_body["data"]["blockchain_enabled"] is True) assert (response_body["data"]["passthrough_enabled"] is True)
def test_save_transaction_hash_for_published_service(self): org_repo.add_item( OrganizationDBModel( name="test_org", org_id="test_org_id", uuid="test_org_uuid", org_type="organization", description="that is the dummy org for testcases", short_description="that is the short description", url="https://dummy.url", contacts=[], assets={}, duns_no=12345678, origin="PUBLISHER_DAPP", groups=[], addresses=[], metadata_ipfs_uri="#dummyhashdummyhash")) new_org_members = [{ "username": "******", "address": "0x123" }, { "username": "******", "address": "0x234" }, { "username": "******", "address": "0x345" }] org_repo.add_all_items([ OrganizationMemberDBModel( username=member["username"], org_uuid="test_org_uuid", role=Role.MEMBER.value, address=member["address"], status=OrganizationMemberStatus.ACCEPTED.value, transaction_hash="0x123", invite_code=str(uuid4()), invited_on=dt.utcnow(), updated_on=dt.utcnow()) for member in new_org_members ]) service_repo.add_item( ServiceDBModel(org_uuid="test_org_uuid", uuid="test_service_uuid", display_name="test_display_name", service_id="test_service_id", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid", state=ServiceStatus.APPROVED.value, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) event = { "path": "/org/test_org_uuid/service/test_service_uuid/transaction", "requestContext": { "authorizer": { "claims": { "email": "*****@*****.**" } } }, "httpMethod": "POST", "pathParameters": { "org_uuid": "test_org_uuid", "service_uuid": "test_service_uuid" }, "body": json.dumps({"transaction_hash": "0xtest_trxn_hash"}) } response = save_transaction_hash_for_published_service(event=event, context=None) assert (response["statusCode"] == 200) response_body = json.loads(response["body"]) assert (response_body["status"] == "success") assert (response_body["data"] == StatusCode.OK)
def test_get_service_metadata_uri(self, mock_ipfs): mock_ipfs.return_value = "QmeoVWV99BJoa9czuxg6AiSyFiyVNNFpcaSMYTQUft785u" org_repo.add_item( OrganizationDBModel( name="test_org", org_id="test_org_id", uuid="test_org_uuid", org_type="organization", description="that is the dummy org for testcases", short_description="that is the short description", url="https://dummy.url", contacts=[], assets={}, duns_no=12345678, origin="PUBLISHER_DAPP", groups=[], addresses=[], metadata_ipfs_uri="#dummyhashdummyhash")) new_org_members = [{ "username": "******", "address": "0x123" }, { "username": "******", "address": "0x234" }, { "username": "******", "address": "0x345" }] org_repo.add_all_items([ OrganizationMemberDBModel( username=member["username"], org_uuid="test_org_uuid", role=Role.MEMBER.value, address=member["address"], status=OrganizationMemberStatus.ACCEPTED.value, transaction_hash="0x123", invite_code=str(uuid4()), invited_on=dt.utcnow(), updated_on=dt.utcnow()) for member in new_org_members ]) service_repo.add_item( ServiceDBModel( org_uuid="test_org_uuid", uuid="test_service_uuid", display_name="test_display_name", service_id="test_service_id", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_long_description", project_url="https://test_project_url.com", proto={ "encoding": "proto", "service_type": "grpc", "model_ipfs_hash": "test_model_ipfs_hash" }, ranking=1, assets={ "proto_files": { "url": "https://ropsten-marketplace-service-assets.s3.amazonaws.com/test_org_uuid/services/test_service_uuid/assets/20200212111248_proto_files.zip" }, "hero_image": { "url": "https://ropsten-marketplace-service-assets.s3.amazonaws.com/ba88d221c5264d6f859e62b15ddd63cf/services/b36f882be79043e18ae0f7c946128b31/assets/20200310063017_asset.png", "ipfs_hash": "" }, "demo_files": { "url": "https://ropsten-marketplace-service-assets.s3.amazonaws.com/ba88d221c5264d6f859e62b15ddd63cf/services/b36f882be79043e18ae0f7c946128b31/component/20200310063120_component.zip" } }, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid", state=ServiceStatus.APPROVED.value, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) event = { "path": "/org/test_org_uuid/service/test_service_uuid/ipfs_publish", "requestContext": { "authorizer": { "claims": { "email": "*****@*****.**" } } }, "httpMethod": "POST", "pathParameters": { "org_uuid": "test_org_uuid", "service_uuid": "test_service_uuid" } } response = publish_service_metadata_to_ipfs(event=event, context=None) assert (response["statusCode"] == 200) response_body = json.loads(response["body"]) assert (response_body["status"] == "success")
def test_verify_service_id(self): org_repo.add_item( OrganizationDBModel( name="test_org", org_id="test_org_id", uuid="test_org_uuid", org_type="organization", description="that is the dummy org for testcases", short_description="that is the short description", url="https://dummy.url", contacts=[], assets={}, duns_no=12345678, origin="PUBLISHER_DAPP", groups=[], addresses=[], metadata_ipfs_uri="#dummyhashdummyhash")) new_org_members = [{ "username": "******", "address": "0x123" }, { "username": "******", "address": "0x234" }, { "username": "******", "address": "0x345" }] org_repo.add_all_items([ OrganizationMemberDBModel( username=member["username"], org_uuid="test_org_uuid", role=Role.MEMBER.value, address=member["address"], status=OrganizationMemberStatus.ACCEPTED.value, transaction_hash="0x123", invite_code=str(uuid4()), invited_on=dt.utcnow(), updated_on=dt.utcnow()) for member in new_org_members ]) service_repo.add_item( ServiceDBModel(org_uuid="test_org_uuid", uuid="test_service_uuid", display_name="test_display_name", service_id="test_service_id", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", proto={}, short_description="test_short_description", description="test_description", project_url="https://dummy.io", assets={}, rating={}, ranking=1, contributors=[], created_on=dt.utcnow(), updated_on=dt.utcnow())) event = { "requestContext": { "authorizer": { "claims": { "email": "*****@*****.**" } } }, "httpMethod": "GET", "pathParameters": { "org_uuid": "test_org_uuid" }, "queryStringParameters": { "service_id": "test_service_id" } } response = verify_service_id(event=event, context=None) assert (response["statusCode"] == 200) response_body = json.loads(response["body"]) assert (response_body["status"] == "success") assert (response_body["data"] == ServiceAvailabilityStatus.UNAVAILABLE.value) event = { "requestContext": { "authorizer": { "claims": { "email": "*****@*****.**" } } }, "httpMethod": "GET", "pathParameters": { "org_uuid": "test_org_uuid" }, "queryStringParameters": { "service_id": "new_test_service_id" } } response = verify_service_id(event=event, context=None) assert (response["statusCode"] == 200) response_body = json.loads(response["body"]) assert (response_body["status"] == "success") assert ( response_body["data"] == ServiceAvailabilityStatus.AVAILABLE.value)
def test_get_services_for_organization(self): org_repo.add_item( OrganizationDBModel( name="test_org", org_id="test_org_id", uuid="test_org_uuid", org_type="organization", description="that is the dummy org for testcases", short_description="that is the short description", url="https://dummy.url", contacts=[], assets={}, duns_no=12345678, origin="PUBLISHER_DAPP", groups=[], addresses=[], metadata_ipfs_uri="#dummyhashdummyhash")) new_org_members = [{ "username": "******", "address": "0x123" }, { "username": "******", "address": "0x234" }, { "username": "******", "address": "0x345" }] org_repo.add_all_items([ OrganizationMemberDBModel( username=member["username"], org_uuid="test_org_uuid", role=Role.MEMBER.value, address=member["address"], status=OrganizationMemberStatus.ACCEPTED.value, transaction_hash="0x123", invite_code=str(uuid4()), invited_on=dt.utcnow(), updated_on=dt.utcnow()) for member in new_org_members ]) service_repo.add_item( ServiceDBModel(org_uuid="test_org_uuid", uuid="test_service_uuid", display_name="test_display_name", service_id="test_service_id", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid", state="DRAFT", transaction_hash=None, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow())) service_repo.add_item( ServiceGroupDBModel(row_id="1000", org_uuid="test_org_uuid", service_uuid="test_service_uuid", group_id="test_group_id", pricing={}, endpoints={ "https://dummydaemonendpoint.io": { "verfied": True } }, daemon_address=["0xq2w3e4rr5t6y7u8i9"], free_calls=10, free_call_signer_address="", created_on=dt.utcnow())) event = { "requestContext": { "authorizer": { "claims": { "email": "*****@*****.**" } } }, "httpMethod": "GET", "pathParameters": { "org_uuid": "test_org_uuid" }, "body": json.dumps({ "q": "display", "limit": 10, "offset": 0, "s": "all", "sort_by": "display_name", "order_by": "desc", "filters": [] }) } response = get_services_for_organization(event=event, context=None) assert (response["statusCode"] == 200) response_body = json.loads(response["body"]) assert (response_body["status"] == "success") assert (response_body["data"]["total_count"] == 1) assert (response_body["data"]["offset"] == 0) assert (response_body["data"]["limit"] == 10) assert (len(response_body["data"]["result"]) == 1)
def setUp(self): org_repo.add_item( OrganizationDBModel( name="test_org", org_id="test_org_id", uuid="test_org_uuid", org_type="organization", description="that is the dummy org for testcases", short_description="that is the short description", url="https://dummy.url", contacts=[], assets={}, duns_no=12345678, origin="PUBLISHER_DAPP", groups=[], addresses=[], metadata_ipfs_uri="#dummyhashdummyhash")) new_org_members = [{"username": "******", "address": "0x123"}] org_repo.add_all_items([ OrganizationMemberDBModel( username=member["username"], org_uuid="test_org_uuid", role=Role.MEMBER.value, address=member["address"], status=OrganizationMemberStatus.ACCEPTED.value, transaction_hash="0x123", invite_code=str(uuid4()), invited_on=dt.utcnow(), updated_on=dt.utcnow()) for member in new_org_members ]) service_repo.add_item( ServiceDBModel( org_uuid="test_org_uuid", uuid="test_service_uuid", display_name="test_display_name", service_id="test_service_id", metadata_uri="Qasdfghjklqwertyuiopzxcvbnm", short_description="test_short_description", description="test_description", project_url="https://dummy.io", ranking=1, assets={ "demo_files": { "url": "https://marketplace-registry-assets.s3.amazonaws.com/6509581150c8446e8a73b3fa71ebdb69/services/05676ad531cd40a889841ff1f3c5608b/component/20210228000436_component.zip", "ipfs_hash": "QmUKfyv5c8Ru93xyxTcXGswnNzuBTCBU9NGjMV7SMwLSgy", "build_id": "sample_build_id" }, "hero_image": { "url": "https://marketplace-registry-assets.s3.amazonaws.com/6509581150c8446e8a73b3fa71ebdb69/services/05676ad531cd40a889841ff1f3c5608b/assets/20210127060152_asset.png", "ipfs_hash": "QmdSh54XcNPJo8v89LRFDN5FAoGL92mn174rKFzoHwUCM1/20210127060152_asset.png" }, "proto_files": { "url": "https://marketplace-registry-assets.s3.amazonaws.com/6509581150c8446e8a73b3fa71ebdb69/services/05676ad531cd40a889841ff1f3c5608b/proto/20210131042033_proto_files.zip", "ipfs_hash": "QmUKfyv5c8Ru93xyxTcXGswnNzuBTCBU9NGjMV7SMwLSgy" } }, created_on=dt.utcnow())) service_repo.add_item( ServiceStateDBModel(row_id=1000, org_uuid="test_org_uuid", service_uuid="test_service_uuid", state=ServiceStatus.APPROVED.value, created_by="dummy_user", updated_by="dummy_user", created_on=dt.utcnow()))