Island: Chande method order in ISimulationRepository

This commit is contained in:
Mike Salvatore 2022-07-01 11:17:56 -04:00
parent bdc5b8fa7b
commit 50a982672e
2 changed files with 17 additions and 17 deletions

View File

@ -14,13 +14,6 @@ class FileSimulationRepository(ISimulationRepository):
self._file_repository = file_repository
self._simulation_schema = SimulationSchema()
def save_simulation(self, simulation: Simulation):
simulation_json = self._simulation_schema.dumps(simulation)
self._file_repository.save_file(
SIMULATION_STATE_FILE_NAME, io.BytesIO(simulation_json.encode())
)
def get_simulation(self) -> Simulation:
try:
with self._file_repository.open_file(SIMULATION_STATE_FILE_NAME) as f:
@ -32,6 +25,13 @@ class FileSimulationRepository(ISimulationRepository):
except Exception as err:
raise RetrievalError(f"Error retrieving the simulation state: {err}")
def save_simulation(self, simulation: Simulation):
simulation_json = self._simulation_schema.dumps(simulation)
self._file_repository.save_file(
SIMULATION_STATE_FILE_NAME, io.BytesIO(simulation_json.encode())
)
def get_mode(self) -> IslandModeEnum:
return self.get_simulation().mode

View File

@ -5,16 +5,6 @@ from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
class ISimulationRepository(ABC):
@abstractmethod
def save_simulation(self, simulation: Simulation):
"""
Save the simulation state
:param simulation: The simulation state
:raises StorageError: If the simulation states could not be saved
"""
pass
@abstractmethod
def get_simulation(self) -> Simulation:
"""
@ -25,6 +15,16 @@ class ISimulationRepository(ABC):
pass
@abstractmethod
def save_simulation(self, simulation: Simulation):
"""
Save the simulation state
:param simulation: The simulation state
:raises StorageError: If the simulation states could not be saved
"""
pass
@abstractmethod
def get_mode(self) -> IslandModeEnum:
"""