Ejemplo n.º 1
0
    def test_close_dispatch_event(self, mocker):
        def foo(h: SimulatorHandler): self.__called = True
        self.__called = False

        s = SimulatorHandler()
        s.start("p", "w")
        s.subscribe(SimulatorEvent.SIMULATION_ENDS, foo)
        s.close()
        assert self.__called
Ejemplo n.º 2
0
 def test_close_not_running_must_not_raise(self):
     s = SimulatorHandler()
     try:
         s.close()
     except:
         raise pytest.fail("Close raised an exception.")  # type: ignore
Ejemplo n.º 3
0
 def test_close_call_network_close(self, mocker):
     s = SimulatorHandler()
     mocker.patch("batsim_py.protocol.NetworkHandler.close")
     s.start("p", "w")
     s.close()
     protocol.NetworkHandler.close.assert_called_once()
Ejemplo n.º 4
0
 def test_close_valid(self):
     s = SimulatorHandler()
     s.start("p", "w")
     s.close()
     assert not s.is_running