Isolated the JsonServer to server.py inside protocols/json Added specific errors for server startup timeout and server startup failed Refactored errors for Core to CoreError generic and refactored StateError to CoreStateMismatchError derived from CoreError
19 lines
446 B
Python
19 lines
446 B
Python
import pytest
|
|
from dynalab_core import Core
|
|
from dynalab_core.config import CoreConfig
|
|
from dynalab_core.errors import CoreStateMismatchError
|
|
from test.common import find_available_port
|
|
|
|
|
|
def test_core_cannot_start_twice() -> None:
|
|
port = find_available_port(8765)
|
|
core = Core(CoreConfig(port=port))
|
|
|
|
core.start()
|
|
|
|
try:
|
|
with pytest.raises(CoreStateMismatchError):
|
|
core.start()
|
|
finally:
|
|
core.stop()
|