Beispiel #1
0
async def test_methods(hass):
    """Test increment, decrement, and reset methods."""
    config = {DOMAIN: {"test_1": {}}}

    assert await async_setup_component(hass, "counter", config)

    entity_id = "counter.test_1"

    state = hass.states.get(entity_id)
    assert 0 == int(state.state)

    async_increment(hass, entity_id)
    await hass.async_block_till_done()

    state = hass.states.get(entity_id)
    assert 1 == int(state.state)

    async_increment(hass, entity_id)
    await hass.async_block_till_done()

    state = hass.states.get(entity_id)
    assert 2 == int(state.state)

    async_decrement(hass, entity_id)
    await hass.async_block_till_done()

    state = hass.states.get(entity_id)
    assert 1 == int(state.state)

    async_reset(hass, entity_id)
    await hass.async_block_till_done()

    state = hass.states.get(entity_id)
    assert 0 == int(state.state)
Beispiel #2
0
async def test_methods(opp):
    """Test increment, decrement, and reset methods."""
    config = {DOMAIN: {"test_1": {}}}

    assert await async_setup_component(opp, "counter", config)

    entity_id = "counter.test_1"

    state = opp.states.get(entity_id)
    assert int(state.state) == 0

    async_increment(opp, entity_id)
    await opp.async_block_till_done()

    state = opp.states.get(entity_id)
    assert int(state.state) == 1

    async_increment(opp, entity_id)
    await opp.async_block_till_done()

    state = opp.states.get(entity_id)
    assert int(state.state) == 2

    async_decrement(opp, entity_id)
    await opp.async_block_till_done()

    state = opp.states.get(entity_id)
    assert int(state.state) == 1

    async_reset(opp, entity_id)
    await opp.async_block_till_done()

    state = opp.states.get(entity_id)
    assert int(state.state) == 0