mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Rewrite core event tests to pytest tests (#40664)
This commit is contained in:
parent
5274b03dc2
commit
0e6d54ea60
@ -268,23 +268,20 @@ async def test_add_job_with_none(hass):
|
||||
hass.async_add_job(None, "test_arg")
|
||||
|
||||
|
||||
class TestEvent(unittest.TestCase):
|
||||
"""A Test Event class."""
|
||||
|
||||
def test_eq(self):
|
||||
def test_event_eq():
|
||||
"""Test events."""
|
||||
now = dt_util.utcnow()
|
||||
data = {"some": "attr"}
|
||||
context = ha.Context()
|
||||
event1, event2 = [
|
||||
ha.Event("some_type", data, time_fired=now, context=context)
|
||||
for _ in range(2)
|
||||
ha.Event("some_type", data, time_fired=now, context=context) for _ in range(2)
|
||||
]
|
||||
|
||||
assert event1 == event2
|
||||
|
||||
def test_repr(self):
|
||||
"""Test that repr method works."""
|
||||
|
||||
def test_event_repr():
|
||||
"""Test that Event repr method works."""
|
||||
assert str(ha.Event("TestEvent")) == "<Event TestEvent[L]>"
|
||||
|
||||
assert (
|
||||
@ -292,8 +289,9 @@ class TestEvent(unittest.TestCase):
|
||||
== "<Event TestEvent[R]: beer=nice>"
|
||||
)
|
||||
|
||||
def test_as_dict(self):
|
||||
"""Test as dictionary."""
|
||||
|
||||
def test_event_as_dict():
|
||||
"""Test as Event as dictionary."""
|
||||
event_type = "some_type"
|
||||
now = dt_util.utcnow()
|
||||
data = {"some": "attr"}
|
||||
@ -310,7 +308,7 @@ class TestEvent(unittest.TestCase):
|
||||
"user_id": event.context.user_id,
|
||||
},
|
||||
}
|
||||
assert expected == event.as_dict()
|
||||
assert event.as_dict() == expected
|
||||
|
||||
|
||||
class TestEventBus(unittest.TestCase):
|
||||
|
Loading…
x
Reference in New Issue
Block a user