当前位置: 首页>>代码示例>>Python>>正文


Python Mock.auth_token方法代码示例

本文整理汇总了Python中unittest.mock.Mock.auth_token方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.auth_token方法的具体用法?Python Mock.auth_token怎么用?Python Mock.auth_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.Mock的用法示例。


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

示例1: test_smartapp_update_syncs_subs

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import auth_token [as 别名]
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,代码行数:29,代码来源:test_smartapp.py

示例2: test_smartapp_install_creates_flow

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import auth_token [as 别名]
async def test_smartapp_install_creates_flow(
        hass, smartthings_mock, config_entry, location):
    """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
    # 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 == \
        len(SUPPORTED_CAPABILITIES)
    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:Martwall,项目名称:home-assistant,代码行数:29,代码来源:test_smartapp.py

示例3: test_smartapp_install_creates_flow

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import auth_token [as 别名]
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,代码行数:35,代码来源:test_smartapp.py

示例4: test_smartapp_install_abort_if_no_other

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import auth_token [as 别名]
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,代码行数:27,代码来源:test_smartapp.py

示例5: test_smartapp_install_abort_if_no_other

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import auth_token [as 别名]
async def test_smartapp_install_abort_if_no_other(hass, smartthings_mock):
    """Test aborts if no other app was configured already."""
    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()

    await smartapp.smartapp_install(hass, request, None, app)

    entries = hass.config_entries.async_entries('smartthings')
    assert not entries
    assert api.create_subscription.call_count == \
        len(SUPPORTED_CAPABILITIES)
开发者ID:Martwall,项目名称:home-assistant,代码行数:19,代码来源:test_smartapp.py

示例6: test_smartapp_install_store_if_no_other

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import auth_token [as 别名]
async def test_smartapp_install_store_if_no_other(
        hass, smartthings_mock, device_factory):
    """Test aborts if no other app was configured already."""
    # Arrange
    app = Mock()
    app.app_id = uuid4()
    request = Mock()
    request.installed_app_id = str(uuid4())
    request.auth_token = str(uuid4())
    request.location_id = str(uuid4())
    request.refresh_token = str(uuid4())
    # Act
    await smartapp.smartapp_install(hass, request, None, app)
    # Assert
    entries = hass.config_entries.async_entries('smartthings')
    assert not entries
    data = hass.data[DOMAIN][CONF_INSTALLED_APPS][0]
    assert data[CONF_REFRESH_TOKEN] == request.refresh_token
    assert data[CONF_LOCATION_ID] == request.location_id
    assert data[CONF_INSTALLED_APP_ID] == request.installed_app_id
开发者ID:boced66,项目名称:home-assistant,代码行数:22,代码来源:test_smartapp.py

示例7: test_smartapp_update_saves_token

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import auth_token [as 别名]
async def test_smartapp_update_saves_token(
        hass, smartthings_mock, location, device_factory):
    """Test update saves token."""
    # Arrange
    entry = Mock()
    entry.data = {
        'installed_app_id': str(uuid4()),
        'app_id': str(uuid4())
    }
    entry.domain = DOMAIN

    setattr(hass.config_entries, '_entries', [entry])
    app = Mock()
    app.app_id = entry.data['app_id']
    request = Mock()
    request.installed_app_id = entry.data['installed_app_id']
    request.auth_token = str(uuid4())
    request.refresh_token = str(uuid4())
    request.location_id = location.location_id

    # Act
    await smartapp.smartapp_update(hass, request, None, app)
    # Assert
    assert entry.data[CONF_REFRESH_TOKEN] == request.refresh_token
开发者ID:boced66,项目名称:home-assistant,代码行数:26,代码来源:test_smartapp.py


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