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

Filter away timestamps from diffs, increase testing. #199

Merged
merged 2 commits into from
Jan 15, 2024

Conversation

terjekv
Copy link
Collaborator

@terjekv terjekv commented Jan 12, 2024

  • This PR filters away timestamps from test results via a regexp.
  • The timestamps are replaced inline so other content in the same value are retained.
  • Adds testing of object history when supported (host, group, atom, role).
  • Moves filtering testing to a host.
  • Will conflict with Prevent group history from iterating over None. #198, due to having to fix group history here as well.

@terjekv terjekv self-assigned this Jan 12, 2024
@terjekv terjekv requested a review from pederhan January 12, 2024 07:24


def group_objects(json_file_path):
def replace_timestamps(obj: Any) -> Any:
Copy link
Member

@pederhan pederhan Jan 15, 2024

Choose a reason for hiding this comment

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

Only consider implementing this if you think replace_timestamps() could actually be called with typed values in the future (currently only Any is passed to it).


Suggested change
def replace_timestamps(obj: Any) -> Any:
from typing import TypeVar
TSType = TypeVar("TSType", str, list, dict)
def replace_timestamps(obj: TSType) -> TSType:

This is not perfect, but provides some very rudimentary type checking:

reveal_type(replace_timestamps("2020-01-01T00:00:00.000Z"))
reveal_type(replace_timestamps(["2020-01-01T00:00:00.000Z", "2020-01-01T00:00:00.000Z"]))
reveal_type(replace_timestamps({"foo": "2020-01-01T00:00:00.000Z"}))
% mypy ci
ci/diff.py:27: note: Revealed type is "builtins.str"
ci/diff.py:28: note: Revealed type is "builtins.list[Any]"
ci/diff.py:29: note: Revealed type is "builtins.dict[Any, Any]"

With a more complicated TypeVar we could get rid of the Any from the returned list and dict type annotations, but that's overkill for something that isn't even part of the CLI itself.

Copy link
Member

@pederhan pederhan left a comment

Choose a reason for hiding this comment

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

LGTM

  - This PR filters away timestamps from test results via a regexp.
  - The timestamps are replaced inline so other content in the same value are retained.
  - Adds testing of object history when supported (host, group, atom, role).
  - Moves filtering testing to a host.
  - Will conflict with unioslo#198, due to having to fix group history here as well.
@terjekv terjekv force-pushed the filter_timestamps_from_diff branch from 92c88f2 to 99b8c4d Compare January 15, 2024 11:51
@terjekv
Copy link
Collaborator Author

terjekv commented Jan 15, 2024

If we're going the typing route, we should probably use a date library and properly parse things, but I'm not sure I see the huge value in this context.

@terjekv terjekv merged commit 519003e into unioslo:master Jan 15, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants