'Test if a web component is found in config panels dir.'

@patch('homeassistant.components.panel_custom.register_panel')
def test_webcomponent_custom_path(self, mock_register, _mock_setup):

    filename = 'mock.file'
    config = {'panel_custom': {'name': 'todomvc', 'webcomponent_path': filename, 'sidebar_title': 'Sidebar    Title', 'sidebar_icon': 'mdi:iconicon', 'url_path': 'nice_url', 'config': 5}}
    with patch('os.path.isfile', Mock(return_value=False)):
        assert (not setup.setup_component(self.hass, 'panel_custom', config))
        assert (not mock_register.called)
    self.hass.data.pop(setup.DATA_SETUP)
    with patch('os.path.isfile', Mock(return_value=True)):
        with patch('os.access', Mock(return_value=True)):
            assert setup.setup_component(self.hass, 'panel_custom', config)
            assert mock_register.called
            args = mock_register.mock_calls[0][1]
            assert (args == (self.hass, 'todomvc', filename))
            kwargs = mock_register.mock_calls[0][2]
            assert (kwargs == {'config': 5, 'url_path': 'nice_url', 'sidebar_icon': 'mdi:iconicon', 'sidebar_title': 'Sidebar    Title'})
