-
Notifications
You must be signed in to change notification settings - Fork 48
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
[PT-5597] Fixing test for catalog class #671
base: master
Are you sure you want to change the base?
Conversation
up42/catalog.py
Outdated
@@ -362,6 +371,7 @@ def download_quicklooks( | |||
try: | |||
url = host.endpoint(f"/catalog/{product_host}/image/{image_id}/quicklook") | |||
response = self.session.get(url) | |||
response.raise_for_status() |
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.
Not needed, our session provides that automatically
up42/catalog.py
Outdated
] | ||
|
||
|
||
class UsageTypeError(ValueError): |
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.
InvalidUsageType
up42/catalog.py
Outdated
@@ -15,6 +15,27 @@ | |||
|
|||
logger = utils.get_logger(__name__) | |||
|
|||
Geometries = Union[ |
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.
Geometry
up42/catalog.py
Outdated
@@ -177,7 +193,7 @@ def construct_search_parameters( | |||
elif usage_type == ["DATA", "ANALYTICS"]: | |||
query_filters["up42:usageType"] = {"in": ["DATA", "ANALYTICS"]} | |||
else: | |||
raise ValueError("Select correct `usage_type`") | |||
raise UsageTypeError("""usage_type only allows ["DATA"], ["ANALYTICS"] or ["DATA", "ANALYTICS"]""") |
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.
raise InvalidUsageType("usage_type is invalid")
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.
usage_type to be declared with type_hint Literal[["DATA"], ["ANALYTICS"], ["DATA", "ANALYTICS"]] instead
up42/catalog.py
Outdated
@@ -324,7 +333,7 @@ def construct_order_parameters( | |||
aoi = utils.fc_to_query_geometry(fc=aoi, geometry_operation="intersects") | |||
order_parameters["params"]["aoi"] = aoi # type: ignore | |||
|
|||
return order_parameters | |||
return cast(order.OrderParams, order_parameters) |
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.
The problem is autocomplete_order_parameters, let's move it to order package and cover by tests. Would be nice to have it in a separate PR to merge before this one
tests/test_catalog.py
Outdated
catalog_obj = catalog.CatalogBase(auth_mock, constants.WORKSPACE_ID) | ||
assert catalog_obj.get_data_product_schema(constants.DATA_PRODUCT_ID) == data_product_schema | ||
|
||
def test_should_place_order_from_catalog_base( |
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.
from_catalog_base is not needed
tests/test_catalog.py
Outdated
[{"type": "ARCHIVE"}, {"type": "TASKING", "orderDetails": {"subStatus": "substatus"}}], | ||
ids=["ARCHIVE", "TASKING"], | ||
) | ||
def test_should_track_order_status_from_catalog_base( |
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.
from_catalog_base is not needed
tests/test_catalog.py
Outdated
report_time=0.1, | ||
) | ||
assert isinstance(order_obj, order.Order) | ||
assert order_obj.track_status(report_time=0.1) == "FULFILLED" |
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.
We just need to check the status and the order id
tests/test_catalog.py
Outdated
|
||
|
||
class TestCatalog: | ||
host = "oneatlas" | ||
catalog = catalog.Catalog(auth=mock.MagicMock(), workspace_id=constants.WORKSPACE_ID) | ||
|
||
@pytest.fixture(params=["output_dir", "no_output_dir"]) | ||
def output_directory(self, request, tmp_path) -> Optional[str]: |
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.
Is tmp_path str?
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.
it is Generator[Path, None, None], a Path object.
up42/catalog.py
Outdated
@@ -91,6 +112,8 @@ class Catalog(CatalogBase): | |||
[CatalogBase](catalogbase-reference.md) class. | |||
""" | |||
|
|||
session = base.Session() |
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.
Duplicate, not needed
Quality Gate passedIssues Measures |
See changelog.
Checklist: