Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rrooggiieerr committed Jul 1, 2024
1 parent 92c7a25 commit 274b598
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 28 deletions.
10 changes: 5 additions & 5 deletions tests/testBenQProjectorSerial.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ async def test__connect(self):
result = await self._projector._connect()
self.assertTrue(result)

async def test__detect_prompt(self):
await self._projector._connect()
result = await self._projector._detect_prompt()
self.assertTrue(result)

async def test__wait_for_prompt(self):
await self._projector._connect()
result = await self._projector._wait_for_prompt()
Expand All @@ -43,8 +48,3 @@ async def test__send_command(self):
await self._projector._wait_for_prompt()
result = await self._projector._send_command("pow")
self.assertTrue(result)


if __name__ == "__main__":
# import sys;sys.argv = ['', 'Test.testName']
unittest.main()
19 changes: 8 additions & 11 deletions tests/testBenQProjectorTelnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

logger = logging.getLogger(__name__)

HOSTNAME = "rs232-bridge.local"
HOSTNAME = "benqprojector-livingroom.local"


class Test(unittest.IsolatedAsyncioTestCase):
_projector = None

async def asyncSetUp(self):
self._projector = BenQProjectorTelnet(HOSTNAME)
self._projector = BenQProjectorTelnet(HOSTNAME, has_prompt=True)

async def asyncTearDown(self):
await self._projector.disconnect()
Expand All @@ -32,22 +32,19 @@ async def test__connect(self):
result = await self._projector._connect()
self.assertTrue(result)

# async def test_connect(self):
# result = await self._projector.connect()
# self.assertTrue(result)
async def test__detect_prompt(self):
await self._projector._connect()
result = await self._projector._detect_prompt()
self.assertTrue(result)

async def test__wait_for_prompt(self):
await self._projector._connect()
result = await self._projector._wait_for_prompt()
self.assertTrue(result)

async def test__send_command(self):
self._projector.has_prompt = True
await self._projector._connect()
await self._projector._wait_for_prompt()
# await self._projector._wait_for_prompt()
result = await self._projector._send_command("pow")
self.assertTrue(result)


if __name__ == "__main__":
# import sys;sys.argv = ['', 'Test.testName']
unittest.main()
7 changes: 2 additions & 5 deletions tests/testBenQSerialConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ async def test_close(self):

async def test_read(self):
await self._connection.open()
await self._connection.write(b"\r")
result = await self._connection.read(1)
logger.debug(result)
self.assertIsNotNone(result)

async def test_readline(self):
await self._connection.open()
await self._connection.write(b"\r")
result = await self._connection.readline()
logger.debug(result)
self.assertIsNotNone(result)
Expand All @@ -58,8 +60,3 @@ async def test_write(self):
await self._connection.readline()
result = await self._connection.readline()
self.assertTrue(result.startswith(b"*POW="))


if __name__ == "__main__":
# import sys;sys.argv = ['', 'Test.testName']
unittest.main()
9 changes: 2 additions & 7 deletions tests/testBenQTelnetConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

logger = logging.getLogger(__name__)

HOSTNAME = "rs232-bridge.local"
HOSTNAME = "benqprojector-livingroom.local"


class Test(unittest.IsolatedAsyncioTestCase):
Expand All @@ -31,7 +31,7 @@ async def asyncTearDown(self):
async def test_open(self):
result = await self._connection.open()
self.assertTrue(result)
self.assertTrue(self._connection.is_open)
self.assertTrue(self._connection.is_open())

async def test_close(self):
await self._connection.open()
Expand Down Expand Up @@ -59,8 +59,3 @@ async def test_write(self):
await self._connection.readline()
result = await self._connection.readline()
self.assertTrue(result.startswith(b"*POW="))


if __name__ == "__main__":
# import sys;sys.argv = ['', 'Test.testName']
unittest.main()

0 comments on commit 274b598

Please sign in to comment.