Add tests on pytest and change dir structure

This commit is contained in:
Dmitriy Bazanov 2023-10-27 00:17:40 +03:00
parent 7f1db9a627
commit 353505239e
4 changed files with 38 additions and 27 deletions

View File

@ -1,14 +0,0 @@
from unittest import TestCase
from controls.device import DeviceLifecycleState
class DeviceLifecycleStateTest(TestCase):
def setUp(self) -> None:
pass
def test_enum(self):
# NOTE: это имеется в виду?
# self.assertEqual(DeviceLifecycleStateTest["INIT"], DeviceLifecycleStateTest.INIT)
self.assertEqual(DeviceLifecycleState["INIT"], DeviceLifecycleState.INIT)

View File

@ -1,13 +0,0 @@
from unittest import TestCase
from equipment.turtle_device import TurtleDevice
class TurtleDeviceTest(TestCase):
def setUp(self) -> None:
self.device = TurtleDevice()
def test_open(self):
self.device.open()
self.device.close()

View File

@ -0,0 +1,7 @@
import pytest
from controls.device import DeviceLifecycleState
def test_enum():
assert DeviceLifecycleState["INIT"] == DeviceLifecycleState.INIT

View File

@ -0,0 +1,31 @@
import pytest
import time
from equipment.turtle_device import TurtleDevice
def test_setup():
td = TurtleDevice() # не падает
def test_read():
td = TurtleDevice()
assert td.read("DEFAULT_ANGLEOFFSET") == 0
def test_write():
td = TurtleDevice()
value_to_pass = 10
td.write("DEFAULT_ANGLEOFFSET", value_to_pass)
assert td["DEFAULT_ANGLEOFFSET"] == value_to_pass
def test_invalidate():
td = TurtleDevice()
value_to_pass = 10
td.write("DEFAULT_ANGLEOFFSET", value_to_pass)
td.invalidate("DEFAULT_ANGLEOFFSET") # сносит логическое значение
assert td["DEFAULT_ANGLEOFFSET"] == 0
def test_execute():
td = TurtleDevice()
td.execute("back", **{"distance": 5.0})
assert td.turtle.pos() == (-5.0 ,0.0)