• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python common.mock_coro函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.common.mock_coro函数的典型用法代码示例。如果您正苦于以下问题:Python mock_coro函数的具体用法?Python mock_coro怎么用?Python mock_coro使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mock_coro函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_controller_no_mac

async def test_controller_no_mac(hass):
    """Test that configured options for a host are loaded via config entry."""
    entry = MockConfigEntry(domain=unifi.DOMAIN, data={
        'controller': {
            'host': '0.0.0.0',
            'username': 'user',
            'password': 'pass',
            'port': 80,
            'site': 'default',
            'verify_ssl': True
        },
        'poe_control': True
    })
    entry.add_to_hass(hass)
    mock_registry = Mock()
    with patch.object(unifi, 'UniFiController') as mock_controller, \
        patch('homeassistant.helpers.device_registry.async_get_registry',
              return_value=mock_coro(mock_registry)):
        mock_controller.return_value.async_setup.return_value = mock_coro(True)
        mock_controller.return_value.mac = None
        assert await unifi.async_setup_entry(hass, entry) is True

    assert len(mock_controller.mock_calls) == 2

    assert len(mock_registry.mock_calls) == 0
开发者ID:ManHammer,项目名称:home-assistant,代码行数:25,代码来源:test_init.py


示例2: test_flow_works

async def test_flow_works(hass, aioclient_mock):
    """Test config flow ."""
    aioclient_mock.get(hue.API_NUPNP, json=[
        {'internalipaddress': '1.2.3.4', 'id': 'bla'}
    ])

    flow = hue.HueFlowHandler()
    flow.hass = hass
    await flow.async_step_init()

    with patch('aiohue.Bridge') as mock_bridge:
        def mock_constructor(host, websession):
            mock_bridge.host = host
            return mock_bridge

        mock_bridge.side_effect = mock_constructor
        mock_bridge.username = 'username-abc'
        mock_bridge.config.name = 'Mock Bridge'
        mock_bridge.config.bridgeid = 'bridge-id-1234'
        mock_bridge.create_user.return_value = mock_coro()
        mock_bridge.initialize.return_value = mock_coro()

        result = await flow.async_step_link(user_input={})

    assert mock_bridge.host == '1.2.3.4'
    assert len(mock_bridge.create_user.mock_calls) == 1
    assert len(mock_bridge.initialize.mock_calls) == 1

    assert result['type'] == 'create_entry'
    assert result['title'] == 'Mock Bridge'
    assert result['data'] == {
        'host': '1.2.3.4',
        'bridge_id': 'bridge-id-1234',
        'username': 'username-abc'
    }
开发者ID:simpss,项目名称:home-assistant,代码行数:35,代码来源:test_hue.py


示例3: test_unload_entry

async def test_unload_entry(hass):
    """Test being able to unload an entry."""
    entry = MockConfigEntry(domain=unifi.DOMAIN, data={
        'controller': {
            'host': '0.0.0.0',
            'username': 'user',
            'password': 'pass',
            'port': 80,
            'site': 'default',
            'verify_ssl': True
        },
        'poe_control': True
    })
    entry.add_to_hass(hass)

    with patch.object(unifi, 'UniFiController') as mock_controller, \
        patch('homeassistant.helpers.device_registry.async_get_registry',
              return_value=mock_coro(Mock())):
        mock_controller.return_value.async_setup.return_value = mock_coro(True)
        mock_controller.return_value.mac = '00:11:22:33:44:55'
        assert await unifi.async_setup_entry(hass, entry) is True

    assert len(mock_controller.return_value.mock_calls) == 1

    mock_controller.return_value.async_reset.return_value = mock_coro(True)
    assert await unifi.async_unload_entry(hass, entry)
    assert len(mock_controller.return_value.async_reset.mock_calls) == 1
    assert hass.data[unifi.DOMAIN] == {}
开发者ID:ManHammer,项目名称:home-assistant,代码行数:28,代码来源:test_init.py


示例4: test_user_permissions_low

async def test_user_permissions_low(hass, aioclient_mock):
    """Test config flow."""
    flow = unifi.UnifiFlowHandler()
    flow.hass = hass

    with patch('aiounifi.Controller') as mock_controller:
        def mock_constructor(host, username, password, port, site, websession):
            """Fake the controller constructor."""
            mock_controller.host = host
            mock_controller.username = username
            mock_controller.password = password
            mock_controller.port = port
            mock_controller.site = site
            return mock_controller

        mock_controller.side_effect = mock_constructor
        mock_controller.login.return_value = mock_coro()
        mock_controller.sites.return_value = mock_coro({
            'site1': {'name': 'default', 'role': 'viewer', 'desc': 'site name'}
        })

        await flow.async_step_user(user_input={
            unifi.CONF_HOST: '1.2.3.4',
            unifi.CONF_USERNAME: 'username',
            unifi.CONF_PASSWORD: 'password',
            unifi.CONF_PORT: 1234,
            unifi.CONF_VERIFY_SSL: True
        })

        result = await flow.async_step_site(user_input={})

    assert result['type'] == 'abort'
开发者ID:ManHammer,项目名称:home-assistant,代码行数:32,代码来源:test_init.py


示例5: test_flow_entry_created_from_user_input

async def test_flow_entry_created_from_user_input() -> None:
    """Test that create data from user input.

    Test when the form should show when no configurations exists
    """
    hass = Mock()
    flow = config_flow.SmhiFlowHandler()
    flow.hass = hass

    test_data = {'name': 'home', CONF_LONGITUDE: '0', CONF_LATITUDE: '0'}

    # Test that entry created when user_input name not exists
    with \
        patch.object(flow, '_show_config_form',
                     return_value=mock_coro()) as config_form, \
        patch.object(flow, '_name_in_configuration_exists',
                     return_value=False), \
        patch.object(flow, '_homeassistant_location_exists',
                     return_value=mock_coro(False)), \
        patch.object(config_flow, 'smhi_locations',
                     return_value={
                         'test': 'something', 'name_exist': 'config'
                         }), \
        patch.object(flow, '_check_location',
                     return_value=mock_coro(True)):

        result = await flow.async_step_user(user_input=test_data)

        assert result['type'] == 'create_entry'
        assert result['data'] == test_data
        assert not config_form.mock_calls
开发者ID:ManHammer,项目名称:home-assistant,代码行数:31,代码来源:test_config_flow.py


示例6: test_flow_entry_created_user_input_faulty

async def test_flow_entry_created_user_input_faulty() -> None:
    """Test that create data from user input and are faulty.

    Test when the form should show when user puts faulty location
    in the config gui. Then the form should show with error
    """
    hass = Mock()
    flow = config_flow.SmhiFlowHandler()
    flow.hass = hass

    test_data = {'name': 'home', CONF_LONGITUDE: '0', CONF_LATITUDE: '0'}

    # Test that entry created when user_input name not exists
    with \
        patch.object(flow, '_check_location',
                     return_value=mock_coro(True)), \
        patch.object(flow, '_show_config_form',
                     return_value=mock_coro()) as config_form, \
        patch.object(flow, '_name_in_configuration_exists',
                     return_value=False), \
        patch.object(flow, '_homeassistant_location_exists',
                     return_value=mock_coro(False)), \
        patch.object(config_flow, 'smhi_locations',
                     return_value={
                         'test': 'something', 'name_exist': 'config'
                         }), \
        patch.object(flow, '_check_location',
                     return_value=mock_coro(False)):

        await flow.async_step_user(user_input=test_data)

        assert len(config_form.mock_calls) == 1
        assert len(flow._errors) == 1
开发者ID:ManHammer,项目名称:home-assistant,代码行数:33,代码来源:test_config_flow.py


示例7: test_flow_show_form_name_exists

async def test_flow_show_form_name_exists() -> None:
    """Test show form if name already exists.

    Test when the form should show when no configurations exists
    """
    hass = Mock()
    flow = config_flow.SmhiFlowHandler()
    flow.hass = hass
    test_data = {'name': 'home', CONF_LONGITUDE: '0', CONF_LATITUDE: '0'}
    # Test show form when home assistant config exists and
    # home is already configured, then new config is allowed
    with \
        patch.object(flow, '_show_config_form',
                     return_value=mock_coro()) as config_form, \
        patch.object(flow, '_name_in_configuration_exists',
                     return_value=True), \
        patch.object(config_flow, 'smhi_locations',
                     return_value={
                         'test': 'something', 'name_exist': 'config'
                         }), \
        patch.object(flow, '_check_location',
                     return_value=mock_coro(True)):

        await flow.async_step_user(user_input=test_data)

        assert len(config_form.mock_calls) == 1
        assert len(flow._errors) == 1
开发者ID:ManHammer,项目名称:home-assistant,代码行数:27,代码来源:test_config_flow.py


示例8: test_smartapp_update_syncs_subs

async def test_smartapp_update_syncs_subs(
        hass, smartthings_mock, config_entry, location, device_factory):
    """Test update synchronizes subscriptions."""
    # Arrange
    setattr(hass.config_entries, '_entries', [config_entry])
    app = Mock()
    app.app_id = config_entry.data['app_id']
    api = smartthings_mock.return_value
    api.delete_subscriptions = Mock()
    api.delete_subscriptions.return_value = mock_coro()
    api.create_subscription.return_value = mock_coro()
    request = Mock()
    request.installed_app_id = str(uuid4())
    request.auth_token = str(uuid4())
    request.location_id = location.location_id
    devices = [
        device_factory('', [Capability.battery, 'ping']),
        device_factory('', [Capability.switch, Capability.switch_level]),
        device_factory('', [Capability.switch])
    ]
    api.devices = Mock()
    api.devices.return_value = mock_coro(return_value=devices)
    # Act
    await smartapp.smartapp_update(hass, request, None, app)
    # Assert
    assert api.create_subscription.call_count == 3
    assert api.delete_subscriptions.call_count == 1
开发者ID:arsaboo,项目名称:home-assistant,代码行数:27,代码来源:test_smartapp.py


示例9: test_smartapp_install_creates_flow

async def test_smartapp_install_creates_flow(
        hass, smartthings_mock, config_entry, location, device_factory):
    """Test installation creates flow."""
    # Arrange
    setattr(hass.config_entries, '_entries', [config_entry])
    api = smartthings_mock.return_value
    api.create_subscription.return_value = mock_coro()
    app = Mock()
    app.app_id = config_entry.data['app_id']
    request = Mock()
    request.installed_app_id = str(uuid4())
    request.auth_token = str(uuid4())
    request.location_id = location.location_id
    devices = [
        device_factory('', [Capability.battery, 'ping']),
        device_factory('', [Capability.switch, Capability.switch_level]),
        device_factory('', [Capability.switch])
    ]
    api.devices = Mock()
    api.devices.return_value = mock_coro(return_value=devices)
    # Act
    await smartapp.smartapp_install(hass, request, None, app)
    # Assert
    await hass.async_block_till_done()
    entries = hass.config_entries.async_entries('smartthings')
    assert len(entries) == 2
    assert api.create_subscription.call_count == 3
    assert entries[1].data['app_id'] == app.app_id
    assert entries[1].data['installed_app_id'] == request.installed_app_id
    assert entries[1].data['location_id'] == request.location_id
    assert entries[1].data['access_token'] == \
        config_entry.data['access_token']
    assert entries[1].title == location.name
开发者ID:arsaboo,项目名称:home-assistant,代码行数:33,代码来源:test_smartapp.py


示例10: test_configurator_callback

async def test_configurator_callback(hass, mock_request):
    """."""
    hass.data[hue.DOMAIN] = {}
    with patch('aiohue.Bridge.create_user',
               side_effect=aiohue.LinkButtonNotPressed):
        await MockBridge(hass).async_setup()

    assert len(mock_request.mock_calls) == 1

    callback = mock_request.mock_calls[0][1][2]

    mock_init = Mock(return_value=mock_coro())
    mock_create = Mock(return_value=mock_coro())

    with patch('aiohue.Bridge') as mock_bridge, \
            patch('homeassistant.helpers.discovery.async_load_platform',
                  return_value=mock_coro()) as mock_load_platform, \
            patch('homeassistant.components.hue.save_json') as mock_save:
        inst = mock_bridge()
        inst.username = 'mock-user'
        inst.create_user = mock_create
        inst.initialize = mock_init
        await callback(None)

    assert len(mock_create.mock_calls) == 1
    assert len(mock_init.mock_calls) == 1
    assert len(mock_save.mock_calls) == 1
    assert mock_save.mock_calls[0][1][1] == {
        '1.2.3.4': {
            'username': 'mock-user'
        }
    }
    assert len(mock_load_platform.mock_calls) == 1
开发者ID:TheRealLink,项目名称:home-assistant,代码行数:33,代码来源:test_bridge.py


示例11: test_service_refresh_devices

async def test_service_refresh_devices(hass):
    """Test that service can refresh devices."""
    entry = MockConfigEntry(domain=deconz.DOMAIN, data={
        'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'
    })
    entry.add_to_hass(hass)
    mock_registry = Mock()

    with patch.object(deconz, 'DeconzGateway') as mock_gateway, \
        patch('homeassistant.helpers.device_registry.async_get_registry',
              return_value=mock_coro(mock_registry)):
        mock_gateway.return_value.async_setup.return_value = mock_coro(True)
        assert await deconz.async_setup_entry(hass, entry) is True

    with patch.object(hass.data[deconz.DOMAIN].api, 'async_load_parameters',
                      return_value=mock_coro(True)):
        await hass.services.async_call(
            'deconz', 'device_refresh', service_data={})
        await hass.async_block_till_done()

    with patch.object(hass.data[deconz.DOMAIN].api, 'async_load_parameters',
                      return_value=mock_coro(False)):
        await hass.services.async_call(
            'deconz', 'device_refresh', service_data={})
        await hass.async_block_till_done()
开发者ID:fbradyirl,项目名称:home-assistant,代码行数:25,代码来源:test_init.py


示例12: async_test_device_join

async def async_test_device_join(
        hass, zha_gateway, cluster_id, domain, device_type=None):
    """Test a newly joining device.

    This creates a new fake device and adds it to the network. It is meant to
    simulate pairing a new device to the network so that code pathways that
    only trigger during device joins can be tested.
    """
    from zigpy.zcl.foundation import Status
    from zigpy.zcl.clusters.general import Basic
    # create zigpy device mocking out the zigbee network operations
    with patch(
            'zigpy.zcl.Cluster.configure_reporting',
            return_value=mock_coro([Status.SUCCESS, Status.SUCCESS])):
        with patch(
                'zigpy.zcl.Cluster.bind',
                return_value=mock_coro([Status.SUCCESS, Status.SUCCESS])):
            zigpy_device = await async_init_zigpy_device(
                hass, [cluster_id, Basic.cluster_id], [], device_type,
                zha_gateway,
                ieee="00:0d:6f:00:0a:90:69:f7",
                manufacturer="FakeMan{}".format(cluster_id),
                model="FakeMod{}".format(cluster_id),
                is_new_join=True)
            cluster = zigpy_device.endpoints.get(1).in_clusters[cluster_id]
            entity_id = make_entity_id(
                domain, zigpy_device, cluster, use_suffix=device_type is None)
            assert hass.states.get(entity_id) is not None
开发者ID:arsaboo,项目名称:home-assistant,代码行数:28,代码来源:common.py


示例13: test_remove_entry_handles_callback_error

async def test_remove_entry_handles_callback_error(hass, manager):
    """Test that exceptions in the remove callback are handled."""
    mock_setup_entry = MagicMock(return_value=mock_coro(True))
    mock_unload_entry = MagicMock(return_value=mock_coro(True))
    mock_remove_entry = MagicMock(
        side_effect=lambda *args, **kwargs: mock_coro())
    loader.set_component(hass, 'test', MockModule(
        'test',
        async_setup_entry=mock_setup_entry,
        async_unload_entry=mock_unload_entry,
        async_remove_entry=mock_remove_entry
    ))
    entry = MockConfigEntry(
        domain='test',
        entry_id='test1',
    )
    entry.add_to_manager(manager)
    # Check all config entries exist
    assert [item.entry_id for item in manager.async_entries()] == \
        ['test1']
    # Setup entry
    await entry.async_setup(hass)
    await hass.async_block_till_done()

    # Remove entry
    result = await manager.async_remove('test1')
    await hass.async_block_till_done()
    # Check that unload went well and so no need to restart
    assert result == {
        'require_restart': False
    }
    # Check the remove callback was invoked.
    assert mock_remove_entry.call_count == 1
    # Check that config entry was removed.
    assert [item.entry_id for item in manager.async_entries()] == []
开发者ID:boced66,项目名称:home-assistant,代码行数:35,代码来源:test_config_entries.py


示例14: test_smartapp_sync_subscriptions_handles_exceptions

async def test_smartapp_sync_subscriptions_handles_exceptions(
        hass, smartthings_mock, device_factory, subscription_factory):
    """Test synchronization does nothing when current."""
    api = smartthings_mock.return_value
    api.delete_subscription.side_effect = \
        lambda loc_id, sub_id: mock_coro(exception=Exception)
    api.create_subscription.side_effect = \
        lambda sub: mock_coro(exception=Exception)
    subscriptions = [
        subscription_factory(Capability.battery),
        subscription_factory(Capability.switch),
        subscription_factory(Capability.switch_level)
    ]
    api.subscriptions.return_value = mock_coro(return_value=subscriptions)
    devices = [
        device_factory('', [Capability.thermostat, 'ping']),
        device_factory('', [Capability.switch, Capability.switch_level]),
        device_factory('', [Capability.switch])
    ]

    await smartapp.smartapp_sync_subscriptions(
        hass, str(uuid4()), str(uuid4()), str(uuid4()), devices)

    assert api.subscriptions.call_count == 1
    assert api.delete_subscription.call_count == 1
    assert api.create_subscription.call_count == 1
开发者ID:boced66,项目名称:home-assistant,代码行数:26,代码来源:test_smartapp.py


示例15: app_fixture

def app_fixture(hass, config_file):
    """Fixture for a single app."""
    app = AppEntity(Mock())
    app.apply_data({
        'appName': APP_NAME_PREFIX + str(uuid4()),
        'appId': str(uuid4()),
        'appType': 'WEBHOOK_SMART_APP',
        'classifications': [CLASSIFICATION_AUTOMATION],
        'displayName': 'Home Assistant',
        'description': "Home Assistant at " + hass.config.api.base_url,
        'singleInstance': True,
        'webhookSmartApp': {
            'targetUrl': webhook.async_generate_url(
                hass, hass.data[DOMAIN][CONF_WEBHOOK_ID]),
            'publicKey': ''}
    })
    app.refresh = Mock()
    app.refresh.return_value = mock_coro()
    app.save = Mock()
    app.save.return_value = mock_coro()
    settings = AppSettings(app.app_id)
    settings.settings[SETTINGS_INSTANCE_ID] = config_file[CONF_INSTANCE_ID]
    app.settings = Mock()
    app.settings.return_value = mock_coro(return_value=settings)
    return app
开发者ID:arsaboo,项目名称:home-assistant,代码行数:25,代码来源:conftest.py


示例16: test_validate_config_ok

def test_validate_config_ok(hass, test_client):
    """Test checking config."""
    app = mock_http_component_app(hass)
    with patch.object(config, 'SECTIONS', ['core']):
        yield from async_setup_component(hass, 'config', {})

    hass.http.views[CheckConfigView.name].register(app.router)
    client = yield from test_client(app)

    with patch(
        'homeassistant.components.config.core.async_check_ha_config_file',
            return_value=mock_coro()):
        resp = yield from client.post('/api/config/core/check_config')

    assert resp.status == 200
    result = yield from resp.json()
    assert result['result'] == 'valid'
    assert result['errors'] is None

    with patch(
        'homeassistant.components.config.core.async_check_ha_config_file',
            return_value=mock_coro('beer')):
        resp = yield from client.post('/api/config/core/check_config')

    assert resp.status == 200
    result = yield from resp.json()
    assert result['result'] == 'invalid'
    assert result['errors'] == 'beer'
开发者ID:danieljkemp,项目名称:home-assistant,代码行数:28,代码来源:test_core.py


示例17: test_cloud_calling_handler

def test_cloud_calling_handler(mock_client, mock_handle_message, mock_cloud):
    """Test we call handle message with correct info."""
    conn = iot.CloudIoT(mock_cloud)
    mock_client.receive.return_value = mock_coro(MagicMock(
        type=WSMsgType.text,
        json=MagicMock(return_value={
            'msgid': 'test-msg-id',
            'handler': 'test-handler',
            'payload': 'test-payload'
        })
    ))
    mock_handle_message.return_value = mock_coro('response')
    mock_client.send_json.return_value = mock_coro(None)

    yield from conn.connect()

    # Check that we sent message to handler correctly
    assert len(mock_handle_message.mock_calls) == 1
    p_hass, p_cloud, handler_name, payload = \
        mock_handle_message.mock_calls[0][1]

    assert p_hass is mock_cloud.hass
    assert p_cloud is mock_cloud
    assert handler_name == 'test-handler'
    assert payload == 'test-payload'

    # Check that we forwarded response from handler to cloud
    assert len(mock_client.send_json.mock_calls) == 1
    assert mock_client.send_json.mock_calls[0][1][0] == {
        'msgid': 'test-msg-id',
        'payload': 'response'
    }
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:32,代码来源:test_iot.py


示例18: test_cloudhook_app_created_then_show_wait_form

async def test_cloudhook_app_created_then_show_wait_form(
        hass, app, app_oauth_client, smartthings_mock):
    """Test SmartApp is created with a cloudhoko and shows wait form."""
    # Unload the endpoint so we can reload it under the cloud.
    await smartapp.unload_smartapp_endpoint(hass)

    mock_async_active_subscription = Mock(return_value=True)
    mock_create_cloudhook = Mock(return_value=mock_coro(
        return_value="http://cloud.test"))
    with patch.object(cloud, 'async_active_subscription',
                      new=mock_async_active_subscription), \
        patch.object(cloud, 'async_create_cloudhook',
                     new=mock_create_cloudhook):

        await smartapp.setup_smartapp_endpoint(hass)

        flow = SmartThingsFlowHandler()
        flow.hass = hass
        smartthings = smartthings_mock.return_value
        smartthings.apps.return_value = mock_coro(return_value=[])
        smartthings.create_app.return_value = \
            mock_coro(return_value=(app, app_oauth_client))
        smartthings.update_app_settings.return_value = mock_coro()
        smartthings.update_app_oauth.return_value = mock_coro()

        result = await flow.async_step_user({'access_token': str(uuid4())})

        assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
        assert result['step_id'] == 'wait_install'
        assert mock_create_cloudhook.call_count == 1
开发者ID:boced66,项目名称:home-assistant,代码行数:30,代码来源:test_config_flow.py


示例19: test_smartapp_install_abort_if_no_other

async def test_smartapp_install_abort_if_no_other(
        hass, smartthings_mock, device_factory):
    """Test aborts if no other app was configured already."""
    # Arrange
    api = smartthings_mock.return_value
    api.create_subscription.return_value = mock_coro()
    app = Mock()
    app.app_id = uuid4()
    request = Mock()
    request.installed_app_id = uuid4()
    request.auth_token = uuid4()
    request.location_id = uuid4()
    devices = [
        device_factory('', [Capability.battery, 'ping']),
        device_factory('', [Capability.switch, Capability.switch_level]),
        device_factory('', [Capability.switch])
    ]
    api.devices = Mock()
    api.devices.return_value = mock_coro(return_value=devices)
    # Act
    await smartapp.smartapp_install(hass, request, None, app)
    # Assert
    entries = hass.config_entries.async_entries('smartthings')
    assert not entries
    assert api.create_subscription.call_count == 3
开发者ID:arsaboo,项目名称:home-assistant,代码行数:25,代码来源:test_smartapp.py


示例20: test_full_flow_implementation

async def test_full_flow_implementation(hass):
    """Test registering an implementation and finishing flow works."""
    gen_authorize_url = Mock(return_value=mock_coro('https://example.com'))
    convert_code = Mock(return_value=mock_coro({'access_token': 'yoo'}))
    config_flow.register_flow_implementation(
        hass, 'test', 'Test', gen_authorize_url, convert_code)
    config_flow.register_flow_implementation(
        hass, 'test-other', 'Test Other', None, None)

    flow = config_flow.NestFlowHandler()
    flow.hass = hass
    result = await flow.async_step_init()
    assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
    assert result['step_id'] == 'init'

    result = await flow.async_step_init({'flow_impl': 'test'})
    assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
    assert result['step_id'] == 'link'
    assert result['description_placeholders'] == {
        'url': 'https://example.com',
    }

    result = await flow.async_step_link({'code': '123ABC'})
    assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
    assert result['data']['tokens'] == {'access_token': 'yoo'}
    assert result['data']['impl_domain'] == 'test'
    assert result['title'] == 'Nest (via Test)'
开发者ID:DavidMStraub,项目名称:home-assistant,代码行数:27,代码来源:test_config_flow.py



注:本文中的tests.common.mock_coro函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.mock_http_component_app函数代码示例发布时间:2022-05-27
下一篇:
Python common.mock_component函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap