Commit 15bc2c12c3e2af8473ab93b801f9cd61880df5e1

Authored by Etienne Pallier
1 parent e68e2cea
Exists in dev

Check fin execution test AgentDeviceTelescopeGemini (mode simu)

src/core/pyros_django/agent/Agent.py
... ... @@ -1003,6 +1003,7 @@ class Agent:
1003 1003 elif cmd.name in ("flush_commands"):
1004 1004 self.print("flush_commands received: Delete all pending commands")
1005 1005 Command.delete_pending_commands_for_agent(self.name)
  1006 + cmd.set_result('DONE')
1006 1007 elif cmd.name in ("abort", "exit", "restart_init"):
1007 1008 #self.printd("Current pending commands are:")
1008 1009 #Command.show_commands(self._pending_commands)
... ... @@ -1013,6 +1014,7 @@ class Agent:
1013 1014 self.DO_RESTART=True
1014 1015 elif cmd.name == "exit":
1015 1016 self.DO_EXIT=True
  1017 + cmd.set_result('SHOULD BE DONE NOW')
1016 1018 else:
1017 1019 name = cmd.name
1018 1020 args = None
... ... @@ -1235,6 +1237,7 @@ class Agent:
1235 1237 #cmdts_res = None
1236 1238  
1237 1239 def simulator_test_results(self):
  1240 + if self.SIMULATOR_COMMANDS_LIST == [] : return
1238 1241 commands = self.simulator_test_results_start()
1239 1242 nb_asserted = self.simulator_test_results_main(commands)
1240 1243 self.simulator_test_results_end(nb_asserted)
... ...
src/core/pyros_django/agent/AgentDevice.py
... ... @@ -224,45 +224,7 @@ class AgentDevice(Agent):
224 224 super().exec_specific_cmd_end(cmd, from_thread)
225 225 '''
226 226  
227   - # @override
228   - def simulator_test_results_main(self, commands):
229   - nb_asserted = 0
230   - for cmd in commands:
231   - if cmd.name == "flush_commands":
232   - assert cmd.is_executed()
233   - nb_asserted+=1
234   - # 2 times
235   - if cmd.name == "go_active":
236   - assert cmd.is_executed()
237   - nb_asserted+=1
238   - # 2 times
239   - if cmd.name == "go_idle":
240   - assert cmd.is_executed()
241   - nb_asserted+=1
242   - """
243   - if cmd.name == "specific0":
244   - assert cmd.is_skipped()
245   - assert cmd.result == "in step #5/5"
246   - nb_asserted+=1
247   - """
248   - if cmd.name == "specific1":
249   - assert cmd.is_killed()
250   - nb_asserted+=1
251   - if cmd.name == "specific2":
252   - assert cmd.is_executed()
253   - assert cmd.result == "in step #5/5"
254   - nb_asserted+=1
255   - if cmd.name == "eval 4+3":
256   - assert cmd.is_executed()
257   - assert cmd.get_result() == "7"
258   - nb_asserted+=1
259   - if cmd.name in ("abort"):
260   - assert cmd.is_executed()
261   - nb_asserted+=1
262   - if cmd.name in ("exit"):
263   - assert cmd.is_executed()
264   - nb_asserted+=1
265   - return nb_asserted
  227 +
266 228  
267 229  
268 230 """
... ...
src/core/pyros_django/agent/AgentDeviceTelescopeGemini.py
... ... @@ -24,14 +24,14 @@ class AgentDeviceTelescopeGemini(AgentDevice):
24 24 # Run this agent in simulator mode
25 25 SIMULATOR_MODE = False
26 26 # Run the assertion tests at the end
27   - SIMULATOR_WITH_TEST = False
  27 + SIMULATOR_WITH_TEST = True
28 28 #SIMULATOR_MAX_DURATION_SEC = None
29 29 SIMULATOR_MAX_DURATION_SEC = 100
30 30 # Who should I send commands to ?
31 31 #SIMULATOR_COMMANDS_DEST = "myself"
32 32 ##SIMULATOR_COMMANDS_DEST = "AgentB"
33 33 # Scenario to be executed
34   - ##SIMULATOR_COMMANDS_LIST = []
  34 + SIMULATOR_COMMANDS_LIST = []
35 35  
36 36  
37 37  
... ... @@ -101,21 +101,21 @@ class AgentDeviceTelescopeGemini(AgentDevice):
101 101  
102 102 cmd="get date"
103 103 res = self._device_ctrl.execute_cmd(cmd)
104   - print("result is", str(res))
  104 + self.printd("result is", str(res))
105 105 if res.ok: print("OK")
106 106 dev_date = str(res)
107 107 time.sleep(1)
108 108  
109 109 cmd="get time"
110 110 res = self._device_ctrl.execute_cmd(cmd)
111   - print("result is", str(res))
  111 + self.printd("result is", str(res))
112 112 if res.ok: print("OK")
113 113 dev_time = str(res)
114 114 time.sleep(1)
115 115  
116 116 cmd="get radec"
117 117 res = self._device_ctrl.execute_cmd(cmd)
118   - print("result is", str(res))
  118 + self.printd("result is", str(res))
119 119 if res.ok: print("OK")
120 120 dev_radec = str(res)
121 121 time.sleep(1)
... ... @@ -124,53 +124,6 @@ class AgentDeviceTelescopeGemini(AgentDevice):
124 124  
125 125  
126 126  
127   - """
128   - =================================================================
129   - FUNCTIONS RUN INSIDE A SUB-THREAD (OR A PROCESS) (thread_*())
130   - =================================================================
131   - """
132   -
133   -
134   - # @override
135   - def simulator_test_results_main(self, commands):
136   - nb_asserted = 0
137   - for cmd in commands:
138   - if cmd.name == "flush_commands":
139   - assert cmd.is_executed()
140   - nb_asserted+=1
141   - # 2 times
142   - if cmd.name == "go_active":
143   - assert cmd.is_executed()
144   - nb_asserted+=1
145   - # 2 times
146   - if cmd.name == "go_idle":
147   - assert cmd.is_executed()
148   - nb_asserted+=1
149   - """
150   - if cmd.name == "specific0":
151   - assert cmd.is_skipped()
152   - assert cmd.result == "in step #5/5"
153   - nb_asserted+=1
154   - """
155   - if cmd.name == "specific1":
156   - assert cmd.is_killed()
157   - nb_asserted+=1
158   - if cmd.name == "specific2":
159   - assert cmd.is_executed()
160   - assert cmd.result == "in step #5/5"
161   - nb_asserted+=1
162   - if cmd.name == "eval 4+3":
163   - assert cmd.is_executed()
164   - assert cmd.get_result() == "7"
165   - nb_asserted+=1
166   - if cmd.name in ("abort"):
167   - assert cmd.is_executed()
168   - nb_asserted+=1
169   - if cmd.name in ("exit"):
170   - assert cmd.is_executed()
171   - nb_asserted+=1
172   - return nb_asserted
173   -
174 127  
175 128 """
176 129 =================================================================
... ...
src/core/pyros_django/agent/AgentTelescopeRequester.py
... ... @@ -19,7 +19,7 @@ class AgentTelescopeRequester(Agent):
19 19 # Run this agent in simulator mode
20 20 SIMULATOR_MODE = True
21 21 # Run the assertion tests at the end
22   - SIMULATOR_WITH_TEST = False
  22 + SIMULATOR_WITH_TEST = True
23 23 #SIMULATOR_MAX_DURATION_SEC = None
24 24 SIMULATOR_MAX_DURATION_SEC = 100
25 25 # Who should I send commands to ?
... ... @@ -195,12 +195,15 @@ class AgentTelescopeRequester(Agent):
195 195 if cmd.name == "go_idle":
196 196 assert cmd.is_executed()
197 197 nb_asserted+=1
  198 + if cmd.name == "get radec":
  199 + assert cmd.is_executed()
  200 + #assert cmd.result == "06:10:38,+89:41:02"
  201 + nb_asserted+=1
198 202 """
199 203 if cmd.name == "specific0":
200 204 assert cmd.is_skipped()
201 205 assert cmd.result == "in step #5/5"
202 206 nb_asserted+=1
203   - """
204 207 if cmd.name == "specific1":
205 208 assert cmd.is_killed()
206 209 nb_asserted+=1
... ... @@ -215,6 +218,7 @@ class AgentTelescopeRequester(Agent):
215 218 if cmd.name in ("abort"):
216 219 assert cmd.is_executed()
217 220 nb_asserted+=1
  221 + """
218 222 if cmd.name in ("exit"):
219 223 assert cmd.is_executed()
220 224 nb_asserted+=1
... ...
src/core/pyros_django/agent/logpyros.py
... ... @@ -15,15 +15,13 @@ import src.core.celme as celme
15 15  
16 16 class LogPyros:
17 17 """
18   -
19 18 Manage PyROS logs in display, file and database.
20   -
  19 +
21 20 First, create an instance:
22 21 log = LogPyros("test",None)
23 22  
24 23 Second, use the print methods to log:
25 24 log.print("Something to log")
26   -
27 25 """
28 26  
29 27 # === Level of log
... ...