mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-05 14:25:45 +00:00
add unittest
This commit is contained in:
parent
26af2ef18b
commit
22588caac5
2 changed files with 79 additions and 9 deletions
70
test/test_broadcast.py
Normal file
70
test/test_broadcast.py
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
/ /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
|
||||
/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
|
||||
German BOS Information Script
|
||||
by Bastian Schroll
|
||||
|
||||
@file: test_broadcast.py
|
||||
@date: 25.09.2018
|
||||
@author: Bastian Schroll
|
||||
@description: Unittests for BOSWatch. File must be _run as "pytest" unittest
|
||||
"""
|
||||
import logging
|
||||
import time
|
||||
import pytest
|
||||
|
||||
from boswatch.network.broadcast import BroadcastServer
|
||||
from boswatch.network.broadcast import BroadcastClient
|
||||
|
||||
|
||||
class Test_Timer:
|
||||
"""!Unittest for the timer class"""
|
||||
|
||||
def setup_method(self, method):
|
||||
logging.debug("[TEST] %s.%s", type(self).__name__, method.__name__)
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def useBroadcastServer(self):
|
||||
"""!Server a BroadcastServer instance"""
|
||||
self.broadcastServer = BroadcastServer()
|
||||
yield 1 # server the server instance
|
||||
if self.broadcastServer.isRunning:
|
||||
assert self.broadcastServer.stop()
|
||||
while self.broadcastServer.isRunning:
|
||||
pass
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def useBroadcastClient(self):
|
||||
"""!Server a BroadcastClient instance"""
|
||||
self.broadcastClient = BroadcastClient()
|
||||
yield 1 # server the server instance
|
||||
|
||||
# tests start here
|
||||
|
||||
def test_serverStartStop(self, useBroadcastServer):
|
||||
assert self.broadcastServer.start()
|
||||
assert self.broadcastServer.isRunning
|
||||
assert self.broadcastServer.stop()
|
||||
|
||||
def test_serverDoubleStart(self, useBroadcastServer):
|
||||
assert self.broadcastServer.start()
|
||||
assert self.broadcastServer.start()
|
||||
assert self.broadcastServer.stop()
|
||||
|
||||
def test_serverStopNotStarted(self, useBroadcastServer):
|
||||
assert self.broadcastServer.stop()
|
||||
|
||||
def test_clientWithoutServer(self, useBroadcastClient):
|
||||
assert not self.broadcastClient.getConnInfo(1)
|
||||
|
||||
def test_serverClientFetchConnInfo(self, useBroadcastServer, useBroadcastClient):
|
||||
assert self.broadcastServer.start()
|
||||
assert self.broadcastClient.getConnInfo()
|
||||
assert self.broadcastServer.stop()
|
||||
assert self.broadcastClient.serverIP
|
||||
assert self.broadcastClient.serverPort
|
||||
Loading…
Add table
Add a link
Reference in a new issue