コード例 #1
0
ファイル: test_cast.py プロジェクト: x86Labs/home-assistant
    def test_filter_duplicates(self, mock_device):
        cast.setup_platform(None, {'host': 'some_host'}, lambda _: _)

        assert mock_device.called

        mock_device.reset_mock()
        assert not mock_device.called

        cast.setup_platform(None, {}, lambda _: _,
                            ('some_host', cast.DEFAULT_PORT))
        assert not mock_device.called
コード例 #2
0
    def test_fallback_cast(self, mock_chromecast, mock_get_chromecasts,
                           mock_device):
        """Test falling back to creating Chromecast when not discovered."""
        mock_get_chromecasts.return_value = [
            FakeChromeCast('some_host', cast.DEFAULT_PORT)
        ]

        # Test chromecasts as if they were hardcoded in configuration.yaml
        cast.setup_platform(self.hass, {'host': 'some_other_host'},
                            lambda _: _)

        assert mock_chromecast.called
        assert mock_device.called
コード例 #3
0
    def test_filter_duplicates(self, mock_device):
        cast.setup_platform(None, {
            'host': 'some_host'
        }, lambda _: _)

        assert mock_device.called

        mock_device.reset_mock()
        assert not mock_device.called

        cast.setup_platform(None, {}, lambda _: _, ('some_host',
                                                    cast.DEFAULT_PORT))
        assert not mock_device.called
コード例 #4
0
    def test_fallback_cast_group(self, mock_chromecast, mock_get_chromecasts,
                                 mock_device):
        """Test not creating Cast Group when not discovered."""
        mock_get_chromecasts.return_value = [
            FakeChromeCast('some_host', cast.DEFAULT_PORT)
        ]

        # Test chromecasts as if they were automatically discovered
        cast.setup_platform(self.hass, {}, lambda _: _, {
            'host': 'some_other_host',
            'port': 43546,
        })
        assert not mock_chromecast.called
        assert not mock_device.called
コード例 #5
0
    def test_fallback_cast_group(self, mock_chromecast, mock_get_chromecasts,
                                 mock_device):
        """Test not creating Cast Group when not discovered."""
        mock_get_chromecasts.return_value = [
            FakeChromeCast('some_host', cast.DEFAULT_PORT)
        ]

        # Test chromecasts as if they were automatically discovered
        cast.setup_platform(self.hass, {}, lambda _: _, {
            'host': 'some_other_host',
            'port': 43546,
        })
        assert not mock_chromecast.called
        assert not mock_device.called
コード例 #6
0
    def test_fallback_cast(self, mock_chromecast, mock_get_chromecasts,
                           mock_device):
        """Test falling back to creating Chromecast when not discovered."""
        mock_get_chromecasts.return_value = [
            FakeChromeCast('some_host', cast.DEFAULT_PORT)
        ]

        # Test chromecasts as if they were hardcoded in configuration.yaml
        cast.setup_platform(self.hass, {
            'host': 'some_other_host'
        }, lambda _: _)

        assert mock_chromecast.called
        assert mock_device.called
コード例 #7
0
ファイル: test_cast.py プロジェクト: loraxx753/skynet
    def test_filter_duplicates(self, mock_get_chromecasts, mock_device):
        """Test filtering of duplicates."""
        mock_get_chromecasts.return_value = [
            FakeChromeCast('some_host', cast.DEFAULT_PORT)
        ]

        # Test chromecasts as if they were hardcoded in configuration.yaml
        cast.setup_platform(None, {'host': 'some_host'}, lambda _: _)

        assert mock_device.called

        mock_device.reset_mock()
        assert not mock_device.called

        # Test chromecasts as if they were automatically discovered
        cast.setup_platform(None, {}, lambda _: _,
                            ('some_host', cast.DEFAULT_PORT))
        assert not mock_device.called
コード例 #8
0
ファイル: test_cast.py プロジェクト: krzynio/home-assistant
    def test_filter_duplicates(self, mock_get_chromecasts, mock_device):
        """Test filtering of duplicates."""
        mock_get_chromecasts.return_value = [
            FakeChromeCast('some_host', cast.DEFAULT_PORT)
        ]

        # Test chromecasts as if they were hardcoded in configuration.yaml
        cast.setup_platform(None, {
            'host': 'some_host'
        }, lambda _: _)

        assert mock_device.called

        mock_device.reset_mock()
        assert not mock_device.called

        # Test chromecasts as if they were automatically discovered
        cast.setup_platform(None, {}, lambda _: _, ('some_host',
                                                    cast.DEFAULT_PORT))
        assert not mock_device.called