mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-01-10 18:49:59 +01:00
add doc strings for tests
This commit is contained in:
parent
c76c179225
commit
69acff24e4
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue