Use project dir end point (#466) #1414
89 tests run, 78 passed, 5 skipped, 6 failed.
Annotations
Check failure on line 148 in tests/jms/test_projects.py
github-actions / Test Report ubuntu-latest:3.12
test_projects.test_project_copy
ansys.hps.client.exceptions.HPSError: Failed to copy projects with ids = ['02y8qZIN8IEAXsZ3lBy5ey'].
Raw output
client = <ansys.hps.client.client.Client object at 0x7ffb6688f320>
def test_project_copy(client):
jms_api = JmsApi(client)
proj_name = f"test_jms_ProjectCopyTest"
proj = Project(name=proj_name, active=True, priority=10)
proj = jms_api.create_project(proj, replace=True)
project_api = ProjectApi(client, proj.id)
> proj1_id = project_api.copy_project()
tests/jms/test_projects.py:148:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py312-coverage/lib/python3.12/site-packages/ansys/hps/client/jms/api/project_api.py:137: in copy_project
r = copy_projects(self, [self.project_id], wait)
.tox/py312-coverage/lib/python3.12/site-packages/ansys/hps/client/jms/api/project_api.py:867: in copy_projects
return _copy_objects(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
client = <ansys.hps.client.client.Client object at 0x7ffb6688f320>
api_url = 'https://localhost:8443/hps/jms/api/v1'
objects = [Project(id='02y8qZIN8IEAXsZ3lBy5ey',name=<marshmallow.missing>,active=<marshmallow.missing>,priority=<marshmallow.missing>,creation_time=<marshmallow.missing>,modification_time=<marshmallow.missing>,statistics=<marshmallow.missing>)]
wait = True
def _copy_objects(
client: Client, api_url: str, objects: List[Object], wait: bool = True
) -> Union[str, List[str]]:
"""Copy objects."""
operation_id = base_copy_objects(client.session, api_url, objects)
if not wait:
return operation_id
op = _monitor_operation(JmsApi(client), operation_id, 1.0)
if not op.succeeded:
obj_type = objects[0].__class__
rest_name = obj_type.Meta.rest_name
> raise HPSError(f"Failed to copy {rest_name} with ids = {[obj.id for obj in objects]}.")
E ansys.hps.client.exceptions.HPSError: Failed to copy projects with ids = ['02y8qZIN8IEAXsZ3lBy5ey'].
.tox/py312-coverage/lib/python3.12/site-packages/ansys/hps/client/jms/api/jms_api.py:402: HPSError
Check failure on line 213 in tests/jms/test_task_definition_templates.py
github-actions / Test Report ubuntu-latest:3.12
test_task_definition_templates.test_template_permissions
AssertionError: assert 'organization' in ['user', 'group', 'anyone']
+ where 'organization' = Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader').permission_type
Raw output
client = <ansys.hps.client.client.Client object at 0x7ffb6688f320>
keycloak_client = <keycloak.keycloak_admin.KeycloakAdmin object at 0x7ffb664fa1e0>
is_admin = True
def test_template_permissions(client, keycloak_client, is_admin):
jms_api = JmsApi(client)
templates = jms_api.get_task_definition_templates()
# a regular deployment should have some default templates
# with read all permissions + some user defined ones with
# either user or group permissions
for template in templates:
permissions = jms_api.get_task_definition_template_permissions(template_id=template.id)
for permission in permissions:
> assert permission.permission_type in ["user", "group", "anyone"]
E AssertionError: assert 'organization' in ['user', 'group', 'anyone']
E + where 'organization' = Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader').permission_type
tests/jms/test_task_definition_templates.py:213: AssertionError
Check failure on line 299 in tests/jms/test_task_definition_templates.py
github-actions / Test Report ubuntu-latest:3.12
test_task_definition_templates.test_template_permissions_update
AssertionError: assert 2 == 1
+ where 2 = len([Permission(permission_type='user',value_id='13cf010a-4090-419d-b00e-3d2919fe57dd',value_name='repadmin',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
Raw output
client = <ansys.hps.client.client.Client object at 0x7ffb6688f320>
def test_template_permissions_update(client):
jms_api = JmsApi(client)
# create new template and check default permissions
template = TaskDefinitionTemplate(name="my_template", version=uuid.uuid4())
template = jms_api.create_task_definition_templates([template])[0]
permissions = jms_api.get_task_definition_template_permissions(template_id=template.id)
> assert len(permissions) == 1
E AssertionError: assert 2 == 1
E + where 2 = len([Permission(permission_type='user',value_id='13cf010a-4090-419d-b00e-3d2919fe57dd',value_name='repadmin',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
tests/jms/test_task_definition_templates.py:299: AssertionError
Check failure on line 324 in tests/jms/test_task_definition_templates.py
github-actions / Test Report ubuntu-latest:3.12
test_task_definition_templates.test_template_anyone_permission
AssertionError: assert 2 == 1
+ where 2 = len([Permission(permission_type='user',value_id='13cf010a-4090-419d-b00e-3d2919fe57dd',value_name='repadmin',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
Raw output
client = <ansys.hps.client.client.Client object at 0x7ffb6688f320>
keycloak_client = <keycloak.keycloak_admin.KeycloakAdmin object at 0x7ffb63394320>
def test_template_anyone_permission(client, keycloak_client):
jms_api = JmsApi(client)
# create new template and check default permissions
template = TaskDefinitionTemplate(name="my_template", version=uuid.uuid4())
template = jms_api.create_task_definition_templates([template])[0]
permissions = jms_api.get_task_definition_template_permissions(template_id=template.id)
> assert len(permissions) == 1
E AssertionError: assert 2 == 1
E + where 2 = len([Permission(permission_type='user',value_id='13cf010a-4090-419d-b00e-3d2919fe57dd',value_name='repadmin',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
tests/jms/test_task_definition_templates.py:324: AssertionError
Check failure on line 394 in tests/jms/test_task_definition_templates.py
github-actions / Test Report ubuntu-latest:3.12
test_task_definition_templates.test_template_delete
AssertionError: assert 2 == 1
+ where 2 = len([Permission(permission_type='user',value_id='944049f0-77a3-49dc-8bb0-41d19bbe68d2',value_name='testuser-b8e67e39',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
Raw output
client = <ansys.hps.client.client.Client object at 0x7ffb6688f320>
keycloak_client = <keycloak.keycloak_admin.KeycloakAdmin object at 0x7ffb63397a40>
def test_template_delete(client, keycloak_client):
auth_api = AuthApi(client)
# create 2 non-admin users
jms_api = JmsApi(client)
user1, client1 = create_new_user_client(client.url, keycloak_client)
assert not auth_api.user_is_admin(user1.id)
jms_api1 = JmsApi(client1)
user2, client2 = create_new_user_client(client.url, keycloak_client)
assert not auth_api.user_is_admin(user2.id)
jms_api2 = JmsApi(client2)
# user1 creates new template
template = TaskDefinitionTemplate(name="my_template", version=uuid.uuid4())
template = jms_api1.create_task_definition_templates([template])[0]
permissions = jms_api1.get_task_definition_template_permissions(template_id=template.id)
> assert len(permissions) == 1
E AssertionError: assert 2 == 1
E + where 2 = len([Permission(permission_type='user',value_id='944049f0-77a3-49dc-8bb0-41d19bbe68d2',value_name='testuser-b8e67e39',role='admin'), Permission(permission_type='organization',value_id='onprem_account',value_name='onprem_account',role='reader')])
tests/jms/test_task_definition_templates.py:394: AssertionError
Check failure on line 71 in tests/test_exceptions.py
github-actions / Test Report ubuntu-latest:3.12
test_exceptions.test_client_error
AssertionError: assert '403 Forbidden' == '404 Not Found'
- 404 Not Found
+ 403 Forbidden
Raw output
url = 'https://localhost:8443/hps', username = 'repadmin', password = 'repadmin'
client = <ansys.hps.client.client.Client object at 0x7ffb6688f320>
def test_client_error(url, username, password, client):
except_obj = None
try:
client = Client(url, username, f"{password}_wrong")
except ClientError as e:
except_obj = e
log.error(str(e))
assert except_obj.reason == "invalid_grant"
assert except_obj.description == "Invalid user credentials"
assert except_obj.response.status_code == 401
except_obj = None
try:
jms_api = JmsApi(client)
jms_api.get_project(id="02q4bg9PVO2OvvhsmClb0E")
except ClientError as e:
except_obj = e
log.error(str(e))
# The answer that one would expect:
# self.assertEqual(except_obj.reason, 'Not Found')
# self.assertEqual(except_obj.response.status_code, 404)
# The answer currently received when querying this with a user different from repadmin
> assert except_obj.reason == "404 Not Found"
E AssertionError: assert '403 Forbidden' == '404 Not Found'
E
E - 404 Not Found
E + 403 Forbidden
tests/test_exceptions.py:71: AssertionError