Update tests with many params
This commit is contained in:
parent
3cd5169c3c
commit
559288a790
@ -1,31 +1,58 @@
|
||||
import pytest
|
||||
import time
|
||||
|
||||
from equipment.turtle_device import TurtleDevice
|
||||
|
||||
|
||||
def test_setup():
|
||||
td = TurtleDevice() # не падает
|
||||
|
||||
def test_read():
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("trait", "value"), [("DEFAULT_MODE", "standard"), ("DEFAULT_ANGLEOFFSET", 0.0)]
|
||||
)
|
||||
def test_read(trait, value):
|
||||
td = TurtleDevice()
|
||||
assert td.read("DEFAULT_ANGLEOFFSET") == 0
|
||||
assert td.read(trait) == value
|
||||
|
||||
def test_write():
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("trait", "value_to_pass"),
|
||||
[
|
||||
("DEFAULT_ANGLEOFFSET", 1),
|
||||
("DEFAULT_ANGLEOFFSET", 2),
|
||||
pytest.param("DEFAULT_ANGLEOFFSET", 3.0, marks=pytest.mark.xfail),
|
||||
("DEFAULT_MODE", "other_mode"),
|
||||
],
|
||||
)
|
||||
def test_write(trait, value_to_pass):
|
||||
td = TurtleDevice()
|
||||
value_to_pass = 10
|
||||
td.write("DEFAULT_ANGLEOFFSET", value_to_pass)
|
||||
assert td["DEFAULT_ANGLEOFFSET"] == value_to_pass
|
||||
td.write(trait, value_to_pass)
|
||||
assert td[trait] == value_to_pass
|
||||
|
||||
def test_invalidate():
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("trait", "value_to_pass"),
|
||||
[
|
||||
("DEFAULT_ANGLEOFFSET", 10),
|
||||
("DEFAULT_MODE", "other mode"),
|
||||
],
|
||||
)
|
||||
def test_invalidate(trait, value_to_pass):
|
||||
td = TurtleDevice()
|
||||
value_to_pass = 10
|
||||
td.write("DEFAULT_ANGLEOFFSET", value_to_pass)
|
||||
td.invalidate("DEFAULT_ANGLEOFFSET") # сносит логическое значение
|
||||
assert td["DEFAULT_ANGLEOFFSET"] == 0
|
||||
td.write(trait, value_to_pass)
|
||||
assert td[trait] != td.read(trait)
|
||||
td.invalidate(trait) # сносит логическое значение
|
||||
assert td[trait] == td.read(trait)
|
||||
|
||||
def test_execute():
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("action", "args", "expected"),
|
||||
[
|
||||
("back", {"distance": 5.0}, (-5.0, 0.0)),
|
||||
pytest.param("back", {"distance": 5.0}, (0.0, -5.0), marks=pytest.mark.xfail),
|
||||
],
|
||||
)
|
||||
def test_execute(action, args, expected):
|
||||
td = TurtleDevice()
|
||||
td.execute("back", **{"distance": 5.0})
|
||||
assert td.turtle.pos() == (-5.0 ,0.0)
|
||||
|
||||
|
||||
td.execute(action, **args)
|
||||
assert td.turtle.pos() == expected
|
||||
|
Loading…
Reference in New Issue
Block a user