Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a google calendar diagnostics platform #101175

Merged
merged 3 commits into from Oct 6, 2023

Conversation

allenporter
Copy link
Contributor

Proposed change

Add a google calendar diagnostics platform which includes redacted events.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there @allenporter 👋

The CI is failing, can you take a look? 👍

../Frenck

@home-assistant
Copy link

home-assistant bot commented Oct 6, 2023

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft October 6, 2023 13:06
@allenporter
Copy link
Contributor Author

Oh interesting, I considered these codecov failures advisory/up to judgement. These are corner cases for internal details about the storage format of the integration that didn't seem worth testing since you have to patch them to get into these weird states. Happy to add that coverage though.

@allenporter
Copy link
Contributor Author

I simplified the code to just handle these cases inline rather than create code branches. Kind of a codecov hack, but the code is a bit simpler in the end.

@frenck
Copy link
Member

frenck commented Oct 6, 2023

@allenporter Don't forget to mark it ready for review when it is done 😉

@allenporter allenporter marked this pull request as ready for review October 6, 2023 14:47
@home-assistant home-assistant bot requested a review from frenck October 6, 2023 14:47
@allenporter
Copy link
Contributor Author

Thank you -- didn't want to spam before it actually passed, but then of course forgot to re-check.

@@ -58,6 +58,35 @@
"defaultReminders": [],
}

TEST_EVENT = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a fixture?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice, but options :)

Maybe for a future PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post merge, following up on the fixture comment since i'm happy to explore it in a future PR.

This is used with mock_events_list_items which is a fixture. That is used at different points in the test to change the next response when events are listed, so the API is now something like:

    mock_events_list_items([TEST_EVENT])

or if testing a special case, something like this:

    mock_events_list_items(
        [
            {
                **TEST_EVENT,
                "id": "event-id-1",
                "iCalUID": "event-id-1@google.com",
                "summary": "All Day Event",
                "start": {"date": "2022-10-08"},
                "end": {"date": "2022-10-09"},
            },
        ]
    )

or for tests that are not using freezer:

    one_hour_from_now = dt_util.now() + datetime.timedelta(minutes=30)
    end_event = one_hour_from_now + datetime.timedelta(minutes=60)
    event = {
        **TEST_EVENT,
        "start": {"dateTime": one_hour_from_now.isoformat()},
        "end": {"dateTime": end_event.isoformat()},
    }
    mock_events_list_items([event])

So its definitely used as an input to a fixture, but its just a variable to help with creating new events for composing them.

So at best we could make another fixture that is a simpler fixture that already takes in the TEST_EVENT as a default and the caller passes in the deltas for the test, but I didn't think having multiple fixtures was worthwhile, and so that is why its composition via TEST_EVENT

If you have other ideas happy to explore them, but also this isn't a pain right now.

Thanks!

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @allenporter 👍

../Frenck

@frenck frenck merged commit 1635cbb into home-assistant:dev Oct 6, 2023
21 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants