Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions tests/jms/test_jms_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import logging
import unittest

from examples.mapdl_motorbike_frame.project_setup import create_project

from ansys.rep.client.jms import JmsApi, ProjectApi
from ansys.rep.client.jms.resource import Job, Project
from tests.rep_test import REPTestCase
Expand All @@ -18,26 +20,20 @@
class REPClientTest(REPTestCase):
def test_jms_api(self):

# This test assumes that the project mapdl_motorbike_frame already exists on the REP server.
# In case, you can create such project running the script
# examples/mapdl_motorbike_frame/project_setup.py

log.debug("=== Client ===")
client = self.client()
proj_name = "Mapdl Motorbike Frame"

log.debug("=== Projects ===")
jms_api = JmsApi(client)
projects = jms_api.get_projects()
log.debug(f"Projects: {[p.id for p in projects]}")
project = None
for p in projects:
if p.name == proj_name:
project = p
project = jms_api.get_project_by_name(name=proj_name)

if project:
log.debug(f"Project: {project.id}")
log.debug(f"project={project}")
else:
log.debug(f"Project {proj_name} not found. Creating it.")
project = create_project(client, proj_name, num_jobs=5, use_exec_script=False)

new_proj = Project(name="New project", active=True)
new_proj = jms_api.create_project(new_proj, replace=True)
Expand Down
5 changes: 4 additions & 1 deletion tests/jms/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ def test_task_integration(self):
proj_name = "Mapdl Motorbike Frame"

jms_api = JmsApi(client)
project = jms_api.get_projects(name=proj_name, sort="-creation_time")[0]
project = jms_api.get_project_by_name(name=proj_name)
if not project:
project = create_project(client, proj_name, num_jobs=5, use_exec_script=False)

project_api = ProjectApi(client, project.id)
tasks = project_api.get_tasks(limit=5)
self.assertEqual(len(tasks), 5)
Expand Down