diff --git a/boswatch/utils/timer.py b/boswatch/utils/timer.py index 8bd82ea..92d1a62 100644 --- a/boswatch/utils/timer.py +++ b/boswatch/utils/timer.py @@ -112,5 +112,5 @@ class RepeatedTimer: @property def lostEvents(self): - """!Property to get a count over all los events""" + """!Property to get a count over all lost events""" return self._lostEvents diff --git a/test/boswatch/test_ServerClient.py b/test/boswatch/test_ServerClient.py index c51bc27..1ba0531 100644 --- a/test/boswatch/test_ServerClient.py +++ b/test/boswatch/test_ServerClient.py @@ -31,12 +31,13 @@ def setup_method(method): @pytest.fixture def getClient(): + """!Build and serve a TCPCLient""" return TCPClient() @pytest.fixture def getServer(): - """!Start and serve the sever for each functions where useServer is given""" + """!Build and serve a TCPServer""" dataQueue = queue.Queue() testServer = TCPServer(dataQueue) return testServer @@ -44,10 +45,10 @@ def getServer(): @pytest.fixture def getRunningServer(getServer): + """!Build and serve a still running TCPServer""" logging.debug("start server") assert getServer.start() - if not getServer.isRunning: - pytest.fail("server not running") + assert getServer.isRunning yield getServer logging.debug("stop server") assert getServer.stop() @@ -108,6 +109,7 @@ def test_clientCommunicate(getClient, getRunningServer): assert getClient.disconnect() +@pytest.mark.skip("needs fixture for more than one client") def test_clientMultiCommunicate(getServer): """!Try to send data to the server with 3 clients and check on '[ack]'""" # connect all @@ -156,6 +158,7 @@ def test_serverDoubleStart(): assert testServer2.stop() +@pytest.mark.skip("needs fixture for more than one client") def test_serverGetOutput(getRunningServer): """!Send data to server with 2 clients, check '[ack]' and data on server queue""" # connect all diff --git a/test/boswatch/test_broadcast.py b/test/boswatch/test_broadcast.py index ce88735..9bda27d 100644 --- a/test/boswatch/test_broadcast.py +++ b/test/boswatch/test_broadcast.py @@ -45,26 +45,31 @@ def broadcastClient(): def test_serverStartStop(broadcastServer): + """!Start a BroadcastServer, check if running and stop it""" assert broadcastServer.start() assert broadcastServer.isRunning assert broadcastServer.stop() def test_serverDoubleStart(broadcastServer): + """!Try to start a BroadcastServer twice""" assert broadcastServer.start() assert broadcastServer.start() assert broadcastServer.stop() def test_serverStopNotStarted(broadcastServer): + """!Try to stop a BroadcastServer where is not running""" assert broadcastServer.stop() def test_clientWithoutServer(broadcastClient): + """!Use BroadcastClient with no server""" assert not broadcastClient.getConnInfo(1) def test_serverClientFetchConnInfo(broadcastClient, broadcastServer): + """!Fetch connection info from BroadcastServer""" assert broadcastServer.start() assert broadcastClient.getConnInfo() assert broadcastServer.stop() diff --git a/test/boswatch/test_config.py b/test/boswatch/test_config.py index 4fd92e1..4e3ca10 100644 --- a/test/boswatch/test_config.py +++ b/test/boswatch/test_config.py @@ -29,11 +29,13 @@ def setup_method(method): @pytest.fixture def getConfig(): + """!Build a config object""" return ConfigYAML() @pytest.fixture def getFilledConfig(): + """!Build a config object and fill it with the config data""" filledConfig = ConfigYAML() assert filledConfig.loadConfigFile(paths.TEST_PATH + "test_config.yaml") is True return filledConfig @@ -55,6 +57,7 @@ def test_loadConfigFileNotFound(getConfig): def test_getTypes(getFilledConfig): + """!Get and check different data types in config""" assert type(getFilledConfig.get("types")) is ConfigYAML assert type(getFilledConfig.get("types", "string")) is str assert type(getFilledConfig.get("types", "bool")) is bool @@ -63,12 +66,14 @@ def test_getTypes(getFilledConfig): def test_getNestedConfig(getFilledConfig): + """!Work with nested sub-config elements""" nestedConfig = getFilledConfig.get("types") assert type(nestedConfig) is ConfigYAML assert nestedConfig.get("string") == "Hello World" def test_configIterationList(getFilledConfig): + """!Try to iterate over a list in the config""" counter = 0 for item in getFilledConfig.get("list"): assert type(item) is str diff --git a/test/boswatch/test_timer.py b/test/boswatch/test_timer.py index d382198..2fb52a1 100644 --- a/test/boswatch/test_timer.py +++ b/test/boswatch/test_timer.py @@ -58,27 +58,32 @@ def useTimerSlow(): def test_timerStartStop(useTimerFast): + """!Try to start and stop a timer""" assert useTimerFast.start() assert useTimerFast.stop() def test_timerDoubleStart(useTimerFast): + """!Try to start a timer twice""" assert useTimerFast.start() assert useTimerFast.start() assert useTimerFast.stop() def test_timerStopNotStarted(useTimerFast): + """!Try to stop a timer where is not started""" assert useTimerFast.stop() def test_timerIsRunning(useTimerFast): + """!Check if a timer is running""" assert useTimerFast.start() assert useTimerFast.isRunning assert useTimerFast.stop() def test_timerRun(useTimerFast): + """!Run a timer and check overdue and lostEvents""" assert useTimerFast.start() time.sleep(0.2) assert useTimerFast.stop() @@ -87,6 +92,7 @@ def test_timerRun(useTimerFast): def test_timerOverdue(useTimerSlow): + """!Run a timer and check overdue and lostEvents""" assert useTimerSlow.start() time.sleep(0.2) assert useTimerSlow.stop() @@ -95,6 +101,7 @@ def test_timerOverdue(useTimerSlow): def test_timerOverdueLong(useTimerSlow): + """!Run a timer and check overdue and lostEvents""" assert useTimerSlow.start() time.sleep(1) assert useTimerSlow.stop()