-
Notifications
You must be signed in to change notification settings - Fork 18
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
Xcube server STAC API now returns a conformant collection time extent #1080
Xcube server STAC API now returns a conformant collection time extent #1080
Conversation
@@ -148,6 +148,16 @@ | |||
} | |||
|
|||
|
|||
def assert_equal_deep_dict(self, dict1, dict2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add this function to test for nested dictionaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. However, you should keep track of the path and output it as part of the error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But actually it is strange why this is needed. TestCase.assertEquals()
actually does a deep equality comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. However, you should keep track of the path and output it as part of the error message.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But actually it is strange why this is needed.
TestCase.assertEquals()
actually does a deep equality comparison.
TestCase.assertEqual()
also checks for the order of the keys in the dictionary, which gives me an error.
@@ -174,7 +184,7 @@ def test_get_datasets_collection_item(self): | |||
"demo-1w", | |||
) | |||
self.assertIsInstance(result, dict) | |||
self.assertCountEqual(self.read_json("stac-datacubes-item.json"), result) | |||
assert_equal_deep_dict(self, self.read_json("stac-datacubes-item.json"), result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, it was only tested that the keys in the first layer of the dictionaries are equal. Now I test the full content of the dictionaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why you define assert_equal_deep_dict
rather than just using self.assertEqual()
, and eventually realized that you presumably need something that's insensitive to the order of iterables within the dictionaries. I suggest adding a short docstring to assert_equal_deep_dict
to explain this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why you define
assert_equal_deep_dict
rather than just usingself.assertEqual()
, and eventually realized that you presumably need something that's insensitive to the order of iterables within the dictionaries. I suggest adding a short docstring toassert_equal_deep_dict
to explain this.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with comments. Please have a look.
@@ -148,6 +148,16 @@ | |||
} | |||
|
|||
|
|||
def assert_equal_deep_dict(self, dict1, dict2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. However, you should keep track of the path and output it as part of the error message.
@@ -632,7 +632,7 @@ def _get_single_dataset_collection( | |||
{"cellsCount": gm.size[1], "resolution": gm.xy_res[1]}, | |||
], | |||
}, | |||
"temporal": {"interval": [[time_interval]], "grid": get_time_grid(dataset)}, | |||
"temporal": {"interval": [time_interval], "grid": get_time_grid(dataset)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, the actual fix.
@@ -102,7 +102,7 @@ def _convert_default(obj: Any) -> Any: | |||
elif np.issubdtype(obj.dtype, np.floating): | |||
return float(obj) | |||
elif np.issubdtype(obj.dtype, np.datetime64): | |||
return np.datetime_as_string(obj, timezone="UTC", unit="s") | |||
return str(np.datetime_as_string(obj, timezone="UTC", unit="s")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment why this is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -148,6 +148,16 @@ | |||
} | |||
|
|||
|
|||
def assert_equal_deep_dict(self, dict1, dict2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But actually it is strange why this is needed. TestCase.assertEquals()
actually does a deep equality comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had one suggestion (see comment), but approving since I don't need to review again.
@@ -174,7 +184,7 @@ def test_get_datasets_collection_item(self): | |||
"demo-1w", | |||
) | |||
self.assertIsInstance(result, dict) | |||
self.assertCountEqual(self.read_json("stac-datacubes-item.json"), result) | |||
assert_equal_deep_dict(self, self.read_json("stac-datacubes-item.json"), result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why you define assert_equal_deep_dict
rather than just using self.assertEqual()
, and eventually realized that you presumably need something that's insensitive to the order of iterables within the dictionaries. I suggest adding a short docstring to assert_equal_deep_dict
to explain this.
Closes #1077
Checklist:
Add docstrings and API docs for any new/modified user-facing classes and functionsNew/modified features documented indocs/source/*
CHANGES.md