Skip to content

Commit

Permalink
merged in master
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Sep 12, 2022
2 parents d50ce76 + e628d13 commit b132943
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spinn_utilities/data/utils_data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,17 @@ def is_stop_already_requested(cls):
raise UnexpectedStateChange(
"Calling stop before run does not make sense")

@classmethod
def is_shutdown(cls):
"""
Determines if simulator has already been shutdown
This returns False in the Mocked state
:rtpye: bool
"""
return cls.__data._run_status == RunStatus.SHUTDOWN

# Report directories
# Remainder in FecDataView

Expand Down
22 changes: 22 additions & 0 deletions unittests/data/test_utils_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_not_setup(self):
self.assertFalse(UtilsDataView.is_user_mode())
with self.assertRaises(SimulatorNotSetupException):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
self.assertFalse(UtilsDataView.is_hard_reset())
self.assertFalse(UtilsDataView.is_soft_reset())
with self.assertRaises(NotImplementedError):
Expand All @@ -74,6 +75,7 @@ def test_mocked(self):
UtilsDataView.check_valid_simulator()
with self.assertRaises(NotImplementedError):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertFalse(UtilsDataView.is_hard_reset())
self.assertFalse(UtilsDataView.is_soft_reset())
Expand Down Expand Up @@ -112,6 +114,7 @@ def test_setup(self):
self.assertTrue(UtilsDataView.is_user_mode())
with self.assertRaises(UnexpectedStateChange):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
UtilsDataView.check_user_can_act()
self.assertFalse(UtilsDataView.is_hard_reset())
Expand Down Expand Up @@ -141,6 +144,7 @@ def check_shut_down(self, writer):
self.assertTrue(UtilsDataView.is_user_mode())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_stop_already_requested()
self.assertTrue(UtilsDataView.is_shutdown())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorShutdownException):
Expand Down Expand Up @@ -181,6 +185,7 @@ def check_stopping(self, writer):
self.assertFalse(UtilsDataView.is_user_mode())
with self.assertRaises(UnexpectedStateChange):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down Expand Up @@ -217,6 +222,7 @@ def test_start(self):
self.assertFalse(UtilsDataView._is_mocked())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertFalse(UtilsDataView.is_stop_already_requested())
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down Expand Up @@ -259,6 +265,7 @@ def check_start_finish(self, writer):
self.assertTrue(UtilsDataView.is_user_mode())
with self.assertRaises(UnexpectedStateChange):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
UtilsDataView.check_user_can_act()
self.assertFalse(UtilsDataView.is_hard_reset())
Expand Down Expand Up @@ -287,6 +294,7 @@ def check_start_finish_shut_down(self, writer):
self.assertTrue(UtilsDataView.is_user_mode())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_stop_already_requested()
self.assertTrue(UtilsDataView.is_shutdown())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorShutdownException):
Expand Down Expand Up @@ -314,6 +322,7 @@ def check_start_finish_stopping(self, writer):
self.assertFalse(UtilsDataView._is_mocked())
with self.assertRaises(UnexpectedStateChange):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
self.assertFalse(UtilsDataView.is_user_mode())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
Expand Down Expand Up @@ -355,6 +364,7 @@ def check_start_finish_hard(self, writer):
self.assertTrue(UtilsDataView.is_user_mode())
with self.assertRaises(UnexpectedStateChange):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
UtilsDataView.check_user_can_act()
self.assertFalse(UtilsDataView.is_soft_reset())
Expand Down Expand Up @@ -385,6 +395,7 @@ def check_start_finish_hard_shut_down(self, writer):
self.assertTrue(UtilsDataView.is_user_mode())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_stop_already_requested()
self.assertTrue(UtilsDataView.is_shutdown())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorShutdownException):
Expand Down Expand Up @@ -414,6 +425,7 @@ def check_start_finish_hard_stopping(self, writer):
self.assertFalse(UtilsDataView._is_mocked())
with self.assertRaises(UnexpectedStateChange):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
self.assertFalse(UtilsDataView.is_user_mode())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
Expand Down Expand Up @@ -456,6 +468,7 @@ def check_start_finish_hard_start(self, writer):
self.assertFalse(UtilsDataView._is_mocked())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertFalse(UtilsDataView.is_stop_already_requested())
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down Expand Up @@ -511,6 +524,7 @@ def check_start_finish_hard_start_request(self, writer):
self.assertFalse(UtilsDataView._is_mocked())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertTrue(UtilsDataView.is_stop_already_requested())
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down Expand Up @@ -565,6 +579,7 @@ def test_start_finish_start(self):
self.assertFalse(UtilsDataView._is_mocked())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertFalse(UtilsDataView.is_stop_already_requested())
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down Expand Up @@ -622,6 +637,7 @@ def test_start_finish_start_request(self):
self.assertFalse(UtilsDataView._is_mocked())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertTrue(UtilsDataView.is_stop_already_requested())
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down Expand Up @@ -683,6 +699,7 @@ def test_start_finish_soft(self):
self.assertTrue(UtilsDataView.is_user_mode())
with self.assertRaises(UnexpectedStateChange):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
UtilsDataView.check_user_can_act()
self.assertTrue(UtilsDataView.is_soft_reset())
Expand Down Expand Up @@ -712,6 +729,7 @@ def check_start_finish_soft_shutdown(self, writer):
self.assertTrue(UtilsDataView.is_user_mode())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_stop_already_requested()
self.assertTrue(UtilsDataView.is_shutdown())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorShutdownException):
Expand Down Expand Up @@ -741,6 +759,7 @@ def check_start_finish_start_soft_stopping(self, writer):
self.assertFalse(UtilsDataView._is_mocked())
with self.assertRaises(UnexpectedStateChange):
UtilsDataView.is_stop_already_requested()
self.assertFalse(UtilsDataView.is_shutdown())
self.assertFalse(UtilsDataView.is_user_mode())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
Expand Down Expand Up @@ -789,6 +808,7 @@ def test_start_finish_soft_start(self):
self.assertFalse(UtilsDataView._is_mocked())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertFalse(UtilsDataView.is_stop_already_requested())
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down Expand Up @@ -849,6 +869,7 @@ def test_start_finish_soft_start_request(self):
self.assertFalse(UtilsDataView._is_mocked())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertTrue(UtilsDataView.is_stop_already_requested())
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down Expand Up @@ -912,6 +933,7 @@ def test_start_request(self):
self.assertFalse(UtilsDataView._is_mocked())
self.assertFalse(UtilsDataView.is_user_mode())
self.assertTrue(UtilsDataView.is_stop_already_requested())
self.assertFalse(UtilsDataView.is_shutdown())
UtilsDataView.check_valid_simulator()
with self.assertRaises(SimulatorRunningException):
UtilsDataView.check_user_can_act()
Expand Down

0 comments on commit b132943

Please sign in to comment.