#PyTest Failures

1 messages ยท Page 1 of 1 (latest)

gloomy pike
#

I have issues with my test setup and cannot run them locally. When pushing to the PR, PR checks fail with

        self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
E       KeyError: 'entry_id'
#

PyTest Failures

hardy nymph
#

Left a comment ๐Ÿ™‚

gloomy pike
#

I basically c&p'ed the test from other integrations that do reauth flows. Hope that makes sense at all.

gloomy pike
#

Next issue ๐Ÿ˜ฆ

  File "/home/runner/work/core/core/homeassistant/components/vicare/__init__.py", line 108, in async_unload_entry
    hass.data[DOMAIN].pop(entry.entry_id)
    ~~~~~~~~~^^^^^^^^
KeyError: 'vicare'
#

Seems my test setup is not correct. In my system the feature works as expected.

hardy nymph
#

Try this, didn't saw that the MockConfigEntry already generates a entry_id

L101++

    config = MockConfigEntry(
        domain=DOMAIN,
        data=VALID_CONFIG,
    )
    config.add_to_hass(hass)

and

context={"source": SOURCE_REAUTH, "entry_id": config.entry_id},
gloomy pike
#

Tests states "unknown flow"..

hardy nymph
#

Yes, same for me locally. I think you don't need those lanes I mentioned in my comment

gloomy pike
#

I think there was a bit too much c&p..

#

removed some lines in the end.