Пример #1
0
    def test_service_groups(self, mock_update, aioclient_mock):
        """Setup component, test groups services."""
        aioclient_mock.put(
            mf.FACE_API_URL.format("persongroups/service_group"),
            status=200,
            text="{}")
        aioclient_mock.delete(
            mf.FACE_API_URL.format("persongroups/service_group"),
            status=200,
            text="{}")

        with assert_setup_component(2, mf.DOMAIN):
            setup_component(self.hass, mf.DOMAIN, self.config)

        mf.create_group(self.hass, 'Service Group')
        self.hass.block_till_done()

        entity = self.hass.states.get('microsoft_face.service_group')
        assert entity is not None
        assert len(aioclient_mock.mock_calls) == 1

        mf.delete_group(self.hass, 'Service Group')
        self.hass.block_till_done()

        entity = self.hass.states.get('microsoft_face.service_group')
        assert entity is None
        assert len(aioclient_mock.mock_calls) == 2
    def test_service_groups(self, mock_update, aioclient_mock):
        """Setup component, test groups services."""
        aioclient_mock.put(
            self.endpoint_url.format("persongroups/service_group"),
            status=200, text="{}"
        )
        aioclient_mock.delete(
            self.endpoint_url.format("persongroups/service_group"),
            status=200, text="{}"
        )

        with assert_setup_component(3, mf.DOMAIN):
            setup_component(self.hass, mf.DOMAIN, self.config)

        mf.create_group(self.hass, 'Service Group')
        self.hass.block_till_done()

        entity = self.hass.states.get('microsoft_face.service_group')
        assert entity is not None
        assert len(aioclient_mock.mock_calls) == 1

        mf.delete_group(self.hass, 'Service Group')
        self.hass.block_till_done()

        entity = self.hass.states.get('microsoft_face.service_group')
        assert entity is None
        assert len(aioclient_mock.mock_calls) == 2
Пример #3
0
    def test_service_status_timeout(self, mock_update, aioclient_mock):
        """Setup component, test groups services with timeout."""
        aioclient_mock.put(
            mf.FACE_API_URL.format("persongroups/service_group"),
            status=400,
            exc=asyncio.TimeoutError())

        with assert_setup_component(2, mf.DOMAIN):
            setup_component(self.hass, mf.DOMAIN, self.config)

        mf.create_group(self.hass, 'Service Group')
        self.hass.block_till_done()

        entity = self.hass.states.get('microsoft_face.service_group')
        assert entity is None
        assert len(aioclient_mock.mock_calls) == 1
Пример #4
0
    def test_service_status_400(self, mock_update, aioclient_mock):
        """Setup component, test groups services with error."""
        aioclient_mock.put(
            mf.FACE_API_URL.format("persongroups/service_group"),
            status=400,
            text="{'error': {'message': 'Error'}}")

        with assert_setup_component(2, mf.DOMAIN):
            setup_component(self.hass, mf.DOMAIN, self.config)

        mf.create_group(self.hass, 'Service Group')
        self.hass.block_till_done()

        entity = self.hass.states.get('microsoft_face.service_group')
        assert entity is None
        assert len(aioclient_mock.mock_calls) == 1
    def test_service_status_timeout(self, mock_update, aioclient_mock):
        """Setup component, test groups services with timeout."""
        aioclient_mock.put(
            self.endpoint_url.format("persongroups/service_group"),
            status=400, exc=asyncio.TimeoutError()
        )

        with assert_setup_component(3, mf.DOMAIN):
            setup_component(self.hass, mf.DOMAIN, self.config)

        mf.create_group(self.hass, 'Service Group')
        self.hass.block_till_done()

        entity = self.hass.states.get('microsoft_face.service_group')
        assert entity is None
        assert len(aioclient_mock.mock_calls) == 1
    def test_service_status_400(self, mock_update, aioclient_mock):
        """Setup component, test groups services with error."""
        aioclient_mock.put(
            self.endpoint_url.format("persongroups/service_group"),
            status=400, text="{'error': {'message': 'Error'}}"
        )

        with assert_setup_component(3, mf.DOMAIN):
            setup_component(self.hass, mf.DOMAIN, self.config)

        mf.create_group(self.hass, 'Service Group')
        self.hass.block_till_done()

        entity = self.hass.states.get('microsoft_face.service_group')
        assert entity is None
        assert len(aioclient_mock.mock_calls) == 1