From d8c22344e768eea7f9ceaca96268f8ed283ca747 Mon Sep 17 00:00:00 2001 From: Dozgulbas Date: Wed, 12 Jun 2024 12:05:29 -0700 Subject: [PATCH] fixing unittests errors --- tests/test_module.py | 30 ++++++---------------- wei.compose.yaml => tests/wei.compose.yaml | 10 ++++---- tests/workcell_defs/test_workcell.yaml | 19 -------------- tests/workflow_defs/test_workflow.yaml | 23 ----------------- 4 files changed, 13 insertions(+), 69 deletions(-) rename wei.compose.yaml => tests/wei.compose.yaml (75%) delete mode 100644 tests/workcell_defs/test_workcell.yaml delete mode 100644 tests/workflow_defs/test_workflow.yaml diff --git a/tests/test_module.py b/tests/test_module.py index faa1d26..6b2b1eb 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -5,8 +5,7 @@ from pathlib import Path import requests - -# from wei.core.data_classes import ModuleAbout, Workcell +from wei import ExperimentClient from wei.types import Workcell @@ -23,7 +22,12 @@ def __init__(self, *args, **kwargs): self.url = f"http://{self.server_host}:{self.server_port}" self.module_url = "http://ur_module:3011" self.redis_host = self.workcell.config.redis_host - + self.experiment = ExperimentClient( + server_host=self.server_host, + server_port=self.server_port, + experiment_name="Test_Experiment", + working_dir=Path(__file__).resolve().parent, + ) # Check to see that server is up start_time = time.time() while True: @@ -35,26 +39,8 @@ def __init__(self, *args, **kwargs): time.sleep(1) if time.time() - start_time > 60: raise TimeoutError("Server did not start in 60 seconds") - while True: - try: - if requests.get(self.module_url + "/state").status_code == 200: - break - except Exception: - pass - time.sleep(1) - if time.time() - start_time > 60: - raise TimeoutError("Module did not start in 60 seconds") - - -# class TestModuleInterfaces(TestWEI_Base): -# """Tests the basic functionality of the Module.""" - -# def test_module_about(self): -# """Tests that the module's /about endpoint works""" -# response = requests.get(self.module_url + "/about") -# assert response.status_code == 200 -# ModuleAbout(**response.json()) if __name__ == "__main__": + t = TestWEI_Base() unittest.main() diff --git a/wei.compose.yaml b/tests/wei.compose.yaml similarity index 75% rename from wei.compose.yaml rename to tests/wei.compose.yaml index c00725f..d616901 100644 --- a/wei.compose.yaml +++ b/tests/wei.compose.yaml @@ -12,22 +12,22 @@ services: environment: - PYTHONUNBUFFERED=1 # Fix weird bug with empty logging volumes: - - ${WORKCELLS_DIR}:/workcell_defs + - ${WORKCELLS_DIR}:/workcells - ${WEI_DATA_DIR}:/home/app/.wei - diaspora_config:/home/app/.diaspora - command: python3 -m wei.server --workcell /workcell_defs/${WORKCELL_FILENAME} + command: python3 -m wei.server --workcell /workcells/${WORKCELL_FILENAME} depends_on: - wei_redis wei_engine: image: ghcr.io/ad-sdl/wei container_name: wei_engine volumes: - - ${WORKCELLS_DIR}:/workcell_defs + - ${WORKCELLS_DIR}:/workcells - ${WEI_DATA_DIR}:/home/app/.wei env_file: .env environment: - PYTHONUNBUFFERED=1 # Fix weird bug with empty logging - command: python3 -m wei.engine --workcell /workcell_defs/${WORKCELL_FILENAME} + command: python3 -m wei.engine --workcell /workcells/${WORKCELL_FILENAME} depends_on: - wei_redis - wei_server @@ -40,7 +40,7 @@ services: - ${REDIS_DIR}:/data command: redis-server --save 60 1 --loglevel warning -################ +################/Users/dozgulbas/workspace/ur_module/workcells/test_workcell.yaml # Data Storage # ################ volumes: diff --git a/tests/workcell_defs/test_workcell.yaml b/tests/workcell_defs/test_workcell.yaml deleted file mode 100644 index 4a61014..0000000 --- a/tests/workcell_defs/test_workcell.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: Test_Workcell - -#Info about data processing and location of the workcell -config: - workcell_origin_coordinates: [0, 0, 0, 0, 0, 0] - redis_host: "wei_redis" - server_host: "wei_server" - server_port: 8000 - -#List of all components accessible in this workcell -modules: - - - name: ur_module - model: Universal Robot UR5e - interface: wei_rest_node - config: - rest_node_address: "http://ur_module:3011" - workcell_coordinates: [0, 0, 0, 0, 0, 0] -locations: {} diff --git a/tests/workflow_defs/test_workflow.yaml b/tests/workflow_defs/test_workflow.yaml deleted file mode 100644 index f8a35f2..0000000 --- a/tests/workflow_defs/test_workflow.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: Test ur_module Module -metadata: - author: Doga Ozgulbas - info: Tests the functionality of the UR Module - version: 0.1 - -modules: - - name: ur_module - -flowdef: - - name: Pick Tool - module: ur_module - action: pick_tool - args: - source: [0.5713, 1.0934, 1.0514, 0.9831, 0, 0, 0.1826] - target: [0.5713, 1.0934, 1.0514, 0.9831, 0, 0, 0.1826] - source_plate_rotation: narrow - target_plate_rotation: narrow - home: [0.5431541204452515, -1.693524023095602, -0.7301170229911804, -2.2898713550963343, 1.567720651626587, -1.0230830351458948] - tool_loc: [0.3131286590368134, 0.15480163498252172, 0.005543999069077835, 3.137978068966478, -0.009313836267512065, -0.0008972976992386885] - payload: 1.2 - docking_axis: y - tool_name: HandE