Commit e6a382bc authored by Joan Pascual Sana's avatar Joan Pascual Sana

Write tests: create and update identities

parent e8cc0f47
......@@ -17,7 +17,7 @@ import unittest
import openapi_client
from openapi_client.models.req_rs_identity_create_identity import ReqRsIdentityCreateIdentity # noqa: E501
from openapi_client.rest import ApiException
from test import API_INSTANCE
class TestReqRsIdentityCreateIdentity(unittest.TestCase):
"""ReqRsIdentityCreateIdentity unit test stubs"""
......@@ -30,8 +30,23 @@ class TestReqRsIdentityCreateIdentity(unittest.TestCase):
def testReqRsIdentityCreateIdentity(self):
"""Test ReqRsIdentityCreateIdentity"""
# FIXME: construct object with mandatory attributes with example values
# model = openapi_client.models.req_rs_identity_create_identity.ReqRsIdentityCreateIdentity() # noqa: E501
api_instance = API_INSTANCE
req_rs_identity_create_identity = {"name": "AnonymousIdTest1",
# "avatar": "( RsGxsImage)Image associated to the identity",
"pseudonimous": True,
# "pgpPassword": "( string)password to unlock PGP to sign identity, not implemented yet"
} # ReqRsIdentityCreateIdentity | name: ( string)Name of the identity avatar: ( RsGxsImage)Image associated to the identity pseudonimous: ( boolean)true for unsigned identity, false otherwise pgpPassword: ( string)password to unlock PGP to sign identity, not implemented yet (optional)
try:
# Create a new identity
api_response = api_instance.rs_identity_create_identity(
req_rs_identity_create_identity=req_rs_identity_create_identity)
print(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->rs_identity_create_identity: %s\n" % e)
pass
......
......@@ -18,6 +18,14 @@ import openapi_client
from openapi_client.models.req_rs_identity_update_identity import ReqRsIdentityUpdateIdentity # noqa: E501
from openapi_client.rest import ApiException
# Used to update the identity
from openapi_client.models.rs_gxs_id_group import RsGxsIdGroup
from openapi_client.models.rs_group_meta_data import RsGroupMetaData
# Used to get identity info
from openapi_client.models.req_rs_identity_get_identities_info import ReqRsIdentityGetIdentitiesInfo
from test import API_INSTANCE
class TestReqRsIdentityUpdateIdentity(unittest.TestCase):
"""ReqRsIdentityUpdateIdentity unit test stubs"""
......@@ -30,8 +38,58 @@ class TestReqRsIdentityUpdateIdentity(unittest.TestCase):
def testReqRsIdentityUpdateIdentity(self):
"""Test ReqRsIdentityUpdateIdentity"""
# FIXME: construct object with mandatory attributes with example values
# model = openapi_client.models.req_rs_identity_update_identity.ReqRsIdentityUpdateIdentity() # noqa: E501
api_instance = API_INSTANCE
# Get all identities info for debugging
# try:
# Get identities summaries list.
# api_response = api_instance.rs_identity_get_own_signed_ids()
# Could be also
# api_response = api_instance.rs_identity_get_identities_summaries()
# print(api_response)
# except ApiException as e:
# print("Exception when calling DefaultApi->rs_identity_get_identities_summaries: %s\n" % e)
# Get the RsGxsIdGroup data for the wanted identity
reqId = 'a96d9b1a009bb96ea6fdd0be053e44c4'
req_rs_identity_get_identities_info = {"ids": [reqId]}
try:
# Get identities information (name, avatar...). Blocking API.
api_response = api_instance.rs_identity_get_identities_info(
req_rs_identity_get_identities_info=req_rs_identity_get_identities_info)
# print(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->rs_identity_get_identities_info: %s\n" % e)
# Now lets get the RsGxsIdGroup object from the array of returned ids
for id in api_response['idsInfo']:
if id['mMeta']['mGroupId'] == reqId:
reqId = id
# Now modify the desired components
print(reqId)
reqId['mMeta']['mGroupName'] = 'AnonymousIdTest2'
# This won't work because the API return the info on camelCase and the object attrs are stored in snake_case
# Todo: modify the openapi generator python template to be camelCase only (to unify with RS project)
# Todo: support to return objects using [out] params on the template generation
# rsGxsIdGroup = RsGxsIdGroup(reqId)
# rsGroupMetaData = RsGroupMetaData(rsGxsIdGroup.m_meta)
# Send the object
req_rs_identity_update_identity = {
"identityData": reqId} # ReqRsIdentityUpdateIdentity | identityData: ( RsGxsIdGroup)updated identiy data (optional)
try:
# Update identity data (name, avatar...)
api_response = api_instance.rs_identity_update_identity(
req_rs_identity_update_identity=req_rs_identity_update_identity)
print(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->rs_identity_update_identity: %s\n" % e)
pass
......
......@@ -26,6 +26,8 @@ Here some test examples to follow:
* [Add shared directory](test/test_req_rs_files_add_shared_directory.py).
* [Create a post with files](test/test_req_rs_gxs_channels_create_post.py):
this have also an example of how to loop through channel summaries.
* [Create an identity](test/test_req_rs_identity_create_identity.py) or
[update it](test/test_req_rs_identity_update_identity.py).
## File uploads
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment