From dc3101dbb0321416433c7e7e63c220c4fb8d4231 Mon Sep 17 00:00:00 2001
From: Detailleur <detailleur@fortiss.org>
Date: Tue, 6 Jul 2021 13:47:55 +0200
Subject: [PATCH] [NRRPLT-8288] useless mock files deleted,
 running-simulation-service test corrected

---
 src/mocks/mock_bibi_configuration.bibi        | 15 -----------
 src/mocks/mock_experiment_configuration.exc   | 26 -------------------
 src/mocks/mock_husky_event.json               | 10 -------
 .../running-simulation-service.test.js        | 24 ++++++++---------
 .../execution/experiment-execution-service.js |  1 -
 .../execution/running-simulation-service.js   |  1 -
 6 files changed, 12 insertions(+), 65 deletions(-)
 delete mode 100644 src/mocks/mock_bibi_configuration.bibi
 delete mode 100644 src/mocks/mock_experiment_configuration.exc
 delete mode 100644 src/mocks/mock_husky_event.json

diff --git a/src/mocks/mock_bibi_configuration.bibi b/src/mocks/mock_bibi_configuration.bibi
deleted file mode 100644
index 5cf4752..0000000
--- a/src/mocks/mock_bibi_configuration.bibi
+++ /dev/null
@@ -1,15 +0,0 @@
-<ns1:bibi 
-  xmlns:ns1="http://schemas.humanbrainproject.eu/SP10/2014/BIBI" 
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <ns1:brainModel>
-    <ns1:file>braitenberg.py</ns1:file>
-    <ns1:populations from="0" population="sensors" to="5" xsi:type="ns1:Range" />
-    <ns1:populations from="5" population="actors" to="8" xsi:type="ns1:Range" />
-    <ns1:populations from="0" population="record" to="8" xsi:type="ns1:Range" />
-  </ns1:brainModel>
-  <ns1:bodyModel robotId="husky">husky_model/model.sdf</ns1:bodyModel>
-  <ns1:transferFunction src="all_neurons_spike_monitor.py" xsi:type="ns1:PythonTransferFunction" />
-  <ns1:transferFunction src="left_wheel_neuron_rate_monitor.py" xsi:type="ns1:PythonTransferFunction" />
-  <ns1:transferFunction src="linear_twist.py" xsi:type="ns1:PythonTransferFunction" />
-  <ns1:transferFunction src="eye_sensor_transmit.py" xsi:type="ns1:PythonTransferFunction" />
-</ns1:bibi>
\ No newline at end of file
diff --git a/src/mocks/mock_experiment_configuration.exc b/src/mocks/mock_experiment_configuration.exc
deleted file mode 100644
index c818ddf..0000000
--- a/src/mocks/mock_experiment_configuration.exc
+++ /dev/null
@@ -1,26 +0,0 @@
-<ExD 
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-  xmlns="http://schemas.humanbrainproject.eu/SP10/2014/ExDConfig" xsi:schemaLocation="http://schemas.humanbrainproject.eu/SP10/2014/ExDConfig ../ExDConfFile.xsd">
-  <name>Holodeck Husky Braitenberg experiment</name>
-  <thumbnail>ExDXMLExample.jpg</thumbnail>
-  <description>This experiment loads the Husky robot from Clearpath Robotics in the Holodeck environment.
-        If the user starts the experiment, the Braitenberg vehicle network is executed
-        and the robot will turn around itself in place, until the camera detects a red color. Then,
-        the robot will move towards the colored object. In this experiment, the user can interact
-        and change the color of both screens by clicking on them with the right mouse button.</description>
-  <tags>husky robotics holodeck braitenberg</tags>
-  <timeout>840</timeout>
-  <configuration type="3d-settings" src="ExDXMLExample.ini" />
-  <configuration type="brainvisualizer" src="brainvisualizer.json" />
-  <configuration type="user-interaction-settings" src="ExDXMLExample.uis" />
-  <maturity>production</maturity>
-  <environmentModel src="virtual_room.sdf">
-    <robotPose robotId="husky" x="0.0" y="0.0" z="0.5" roll="0.0" pitch="-0.0" yaw="3.14159265359" />
-  </environmentModel>
-  <bibiConf src="bibi_configuration.bibi" />
-  <cameraPose>
-    <cameraPosition x="5.056825994369357" y="-1.0210998541555323" z="2.697598759953974" />
-    <cameraLookAt x="0" y="0" z="0.49999" />
-  </cameraPose>
-  <cloneDate>2021-07-05T15:20:29</cloneDate>
-</ExD>
\ No newline at end of file
diff --git a/src/mocks/mock_husky_event.json b/src/mocks/mock_husky_event.json
deleted file mode 100644
index 89e1ad9..0000000
--- a/src/mocks/mock_husky_event.json
+++ /dev/null
@@ -1,10 +0,0 @@
-[
-  {
-    "webkitRelativePath": "./mock_experiment_configuration.exc",
-    "type": "exc"
-  },
-  {
-    "webkitRelativePath": "./mock_bibi_configuration.bibi",
-    "type": "bibi"
-  }
-]
\ No newline at end of file
diff --git a/src/services/experiments/execution/__tests__/running-simulation-service.test.js b/src/services/experiments/execution/__tests__/running-simulation-service.test.js
index d93d973..12fc0bc 100644
--- a/src/services/experiments/execution/__tests__/running-simulation-service.test.js
+++ b/src/services/experiments/execution/__tests__/running-simulation-service.test.js
@@ -109,32 +109,32 @@ test('register for ROS status information', () => {
   });
   let progressMessageCallback = jest.fn();
 
-  // we register twice to check that original sub is destroyed and re-created without error
+  // we register twice to check that the original sub is conserved without error
   RunningSimulationService.instance.addRosStatusInfoCallback('test-ros-ws-url', progressMessageCallback);
   RunningSimulationService.instance.addRosStatusInfoCallback('test-ros-ws-url', progressMessageCallback);
-  expect(RoslibService.instance.getConnection.mock.calls.length).toBe(2);
-  expect(mockStatusListener.removeAllListeners.mock.calls.length).toBe(1);
+  expect(RoslibService.instance.getConnection.mock.calls.length).toBe(1);
+  expect(mockStatusListener.removeAllListeners.mock.calls.length).toBe(0);
 
   // send status update with task info
   let rosStatusData = {
-    progress: {
-      task: 'test-some-task',
-      subtask: 'test-some-subtask'
-    }
+    task: 'test-some-task',
+    subtask: 'test-some-subtask'
   };
   statusUpdateCallback({ data: JSON.stringify(rosStatusData) });
   expect(progressMessageCallback).toHaveBeenCalledWith({
-    main: rosStatusData.progress.task,
-    sub: rosStatusData.progress.subtask
+    task: rosStatusData.task,
+    subtask: rosStatusData.subtask
   });
 
   // send status update indicating we're done
-  rosStatusData.progress.done = true;
+  rosStatusData = {
+    done: true
+  }
   statusUpdateCallback({ data: JSON.stringify(rosStatusData) });
   expect(progressMessageCallback).toHaveBeenCalledWith({
-    main: 'Simulation initialized.'
+    done: true
   });
-  expect(mockStatusListener.removeAllListeners.mock.calls.length).toBe(2);
+  expect(mockStatusListener.removeAllListeners.mock.calls.length).toBe(0);
 });
 
 test('can retrieve the state of a simulation', async () => {
diff --git a/src/services/experiments/execution/experiment-execution-service.js b/src/services/experiments/execution/experiment-execution-service.js
index 54f01f6..58f512d 100644
--- a/src/services/experiments/execution/experiment-execution-service.js
+++ b/src/services/experiments/execution/experiment-execution-service.js
@@ -60,7 +60,6 @@ class ExperimentExecutionService extends HttpService {
 
     let brainProcesses = launchSingleMode ? 1 : experiment.configuration.brainProcesses;
 
-    //TODO: placeholder, register actual progress callback later
     let progressCallback = (msg) => {
       if (msg && msg.progress) {
         if (msg.progress.done) {
diff --git a/src/services/experiments/execution/running-simulation-service.js b/src/services/experiments/execution/running-simulation-service.js
index 49590e5..c4df84c 100644
--- a/src/services/experiments/execution/running-simulation-service.js
+++ b/src/services/experiments/execution/running-simulation-service.js
@@ -126,7 +126,6 @@ class SimulationService extends HttpService {
 
     // remove the progress bar callback only, unsubscribe terminates the rosbridge
     // connection for any other subscribers on the status topic
-    statusTopic.unsubscribe(); // fully disconnects rosbridge
     statusTopic.removeAllListeners();
     rosStatusTopics.delete(rosbridgeWebsocket);
   }
-- 
GitLab