Skip to content

Commit

Permalink
Use call_count instead of await_count
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Jul 24, 2024
1 parent 8b3cd6b commit 8752c61
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/test_ezsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ async def test_ezsp_init(conn_mock, reset_mock, version_mock):
"""Test initialize method."""
zigpy_config = config.CONFIG_SCHEMA({"device": DEVICE_CONFIG})
await ezsp.EZSP.initialize(zigpy_config)
assert conn_mock.await_count == 1
assert reset_mock.await_count == 1
assert version_mock.await_count == 1
assert conn_mock.call_count == 1
assert reset_mock.call_count == 1

Check failure on line 295 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.8.14

test_ezsp_init AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='140017120504176'>.call_count

Check failure on line 295 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.9.15

test_ezsp_init AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='139884112806528'>.call_count

Check failure on line 295 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.10.8

test_ezsp_init AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='140025822973328'>.call_count

Check failure on line 295 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.12

test_ezsp_init AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='140411384942512'>.call_count
assert version_mock.call_count == 1


@patch.object(ezsp.EZSP, "version", side_effect=RuntimeError("Uh oh"))
Expand All @@ -307,9 +307,9 @@ async def test_ezsp_init_failure(conn_mock, close_mock, reset_mock, version_mock
with pytest.raises(RuntimeError):
await ezsp.EZSP.initialize(zigpy_config)

assert conn_mock.await_count == 1
assert reset_mock.await_count == 1
assert version_mock.await_count == 1
assert conn_mock.call_count == 1
assert reset_mock.call_count == 1

Check failure on line 311 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.8.14

test_ezsp_init_failure AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='140017122568656'>.call_count

Check failure on line 311 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.9.15

test_ezsp_init_failure AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='139884102812432'>.call_count

Check failure on line 311 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.10.8

test_ezsp_init_failure AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='140025822969664'>.call_count

Check failure on line 311 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.12

test_ezsp_init_failure AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='140411385605504'>.call_count
assert version_mock.call_count == 1
assert close_mock.call_count == 1


Expand Down Expand Up @@ -396,22 +396,22 @@ async def test_pre_permit(ezsp_f):
with patch("bellows.ezsp.v4.EZSPv4.pre_permit") as pre_mock:
await ezsp_f.pre_permit(sentinel.time)
assert pre_mock.call_count == 1
assert pre_mock.await_count == 1
assert pre_mock.call_count == 1


async def test_update_policies(ezsp_f):
with patch("bellows.ezsp.v4.EZSPv4.update_policies") as pol_mock:
await ezsp_f.update_policies(sentinel.time)
assert pol_mock.call_count == 1
assert pol_mock.await_count == 1
assert pol_mock.call_count == 1


async def test_set_source_routing_set_concentrator(ezsp_f):
"""Test enabling source routing."""
with patch.object(ezsp_f, "setConcentrator", new=AsyncMock()) as cnc_mock:
cnc_mock.return_value = (t.EmberStatus.SUCCESS,)
await ezsp_f.set_source_routing()
assert cnc_mock.await_count == 1
assert cnc_mock.call_count == 1

cnc_mock.return_value = (t.EmberStatus.ERR_FATAL,)
await ezsp_f.set_source_routing()
Expand Down Expand Up @@ -634,10 +634,10 @@ async def test_ezsp_init_zigbeed(conn_mock, reset_mock, version_mock):

await ezsp.EZSP.initialize(zigpy_config)

assert conn_mock.await_count == 1
assert conn_mock.call_count == 1
assert reset_mock.await_count == 0 # Reset is not called
assert gw_wait_reset_mock.await_count == 1
assert version_mock.await_count == 1
assert gw_wait_reset_mock.call_count == 1
assert version_mock.call_count == 1


@patch.object(ezsp.EZSP, "version", new_callable=AsyncMock)
Expand All @@ -664,10 +664,10 @@ async def wait_forever(*args, **kwargs):

await ezsp.EZSP.initialize(zigpy_config)

assert conn_mock.await_count == 1
assert reset_mock.await_count == 1 # Reset will be called
assert gw_wait_reset_mock.await_count == 1
assert version_mock.await_count == 1
assert conn_mock.call_count == 1
assert reset_mock.call_count == 1 # Reset will be called

Check failure on line 668 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.8.14

test_ezsp_init_zigbeed_timeout AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='140017115195040'>.call_count

Check failure on line 668 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.9.15

test_ezsp_init_zigbeed_timeout AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='139884111408672'>.call_count

Check failure on line 668 in tests/test_ezsp.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.10.8

test_ezsp_init_zigbeed_timeout AssertionError: assert 0 == 1 + where 0 = <AsyncMock name='reset' id='140025833505312'>.call_count
assert gw_wait_reset_mock.call_count == 1
assert version_mock.call_count == 1


async def test_wait_for_stack_status(ezsp_f):
Expand Down

0 comments on commit 8752c61

Please sign in to comment.