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

[PT-5597] Fixing test for catalog class #671

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

andher1802
Copy link
Contributor

See changelog.

Checklist:

  • Test coverage
  • Version bump
  • Changelog update

tests/test_catalog.py Outdated Show resolved Hide resolved
@andher1802 andher1802 marked this pull request as ready for review September 12, 2024 20:58
@andher1802 andher1802 requested review from up42-eva and a team as code owners September 12, 2024 20:58
@andher1802 andher1802 changed the title [PT-5597] Fixing test for catalog clas [PT-5597] Fixing test for catalog class Sep 13, 2024
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()
Copy link
Contributor

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):
Copy link
Contributor

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[
Copy link
Contributor

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"]""")
Copy link
Contributor

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")

Copy link
Contributor

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)
Copy link
Contributor

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

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(
Copy link
Contributor

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

[{"type": "ARCHIVE"}, {"type": "TASKING", "orderDetails": {"subStatus": "substatus"}}],
ids=["ARCHIVE", "TASKING"],
)
def test_should_track_order_status_from_catalog_base(
Copy link
Contributor

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

report_time=0.1,
)
assert isinstance(order_obj, order.Order)
assert order_obj.track_status(report_time=0.1) == "FULFILLED"
Copy link
Contributor

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



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]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is tmp_path str?

Copy link
Contributor Author

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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate, not needed

Copy link

sonarcloud bot commented Sep 26, 2024

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