diff --git a/CHANGELOG.md b/CHANGELOG.md index 02f58376f..096926000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,12 @@ You can check your current version with the following command: ``` For more information, see [UP42 Python package description](https://pypi.org/project/up42-py/). +## 2.1.1a13 + +**Dec 4, 2024** +- Move `tests/fixtures/fixtures_globals.py` to `tests/constants.py`. +- Move constants used in a single test module to the corresponding module. + ## 2.1.1a12 **Dec 3, 2024** diff --git a/pyproject.toml b/pyproject.toml index 208fd35e5..20df7bdd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "up42-py" -version = "2.1.1a12" +version = "2.1.1a13" description = "Python SDK for UP42, the geospatial marketplace and developer platform." authors = ["UP42 GmbH "] license = "https://github.com/up42/up42-py/blob/master/LICENSE" diff --git a/tests/conftest.py b/tests/conftest.py index f2dfe9080..29903c7a5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,10 +3,9 @@ import pytest import requests +from tests import constants from up42 import host -from .fixtures import fixtures_globals as constants - @pytest.fixture(autouse=True) def restore_default_domain(): diff --git a/tests/constants.py b/tests/constants.py new file mode 100644 index 000000000..d49fc440b --- /dev/null +++ b/tests/constants.py @@ -0,0 +1,58 @@ +TOKEN = "token_123" +API_HOST = "https://api.up42.com" +WORKSPACE_ID = "workspace_id_123" +USER_EMAIL = "user@up42.com" +PASSWORD = "" +DATA_PRODUCT_ID = "47dadb27-9532-4552-93a5-48f70a83eaef" +ORDER_ID = "da2310a2-c7fb-42ed-bead-fb49ad862c67" +URL_STAC_CATALOG = f"{API_HOST}/v2/assets/stac/" +URL_STAC_SEARCH = f"{API_HOST}/v2/assets/stac/search" + +STAC_CATALOG_RESPONSE = { + "conformsTo": [ + "https://api.stacspec.org/v1.0.0-rc.1/item-search#sort", + "https://api.stacspec.org/v1.0.0-rc.1/collections", + "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter", + "http://www.opengis.net/spec/ogcapi-features-4/1.0/conf/simpletx", + "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:basic-cql", + "https://api.stacspec.org/v1.0.0-rc.1/item-search", + "https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features/extensions/transaction", + "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:cql-text", + "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter", + "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter", + "https://api.stacspec.org/v1.0.0-rc.1/core", + "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core", + "https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features", + "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson", + "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30", + ], + "links": [ + { + "href": URL_STAC_CATALOG, + "rel": "self", + "type": "application/json", + }, + { + "href": URL_STAC_CATALOG, + "rel": "root", + "type": "application/json", + }, + { + "href": "https://api.up42.com/v2/assets/stac/collections", + "rel": "data", + "type": "application/json", + }, + { + "href": URL_STAC_SEARCH, + "rel": "search", + "type": "application/json", + "method": "POST", + }, + ], + "stac_extensions": [], + "title": "UP42 Storage", + "description": "UP42 Storage STAC API", + "stac_version": "1.0.0", + "id": "up42-storage", + "type": "Catalog", +} diff --git a/tests/fixtures/__init__.py b/tests/fixtures/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/fixtures/fixtures_globals.py b/tests/fixtures/fixtures_globals.py deleted file mode 100644 index ddd73cded..000000000 --- a/tests/fixtures/fixtures_globals.py +++ /dev/null @@ -1,141 +0,0 @@ -TOKEN = "token_123" -API_HOST = "https://api.up42.com" -TOKEN_ENDPOINT = "https://auth.up42.com/realms/public/protocol/openid-connect/token" - -WORKSPACE_ID = "workspace_id_123" -USER_ID = "1094497b-11d8-4fb8-9d6a-5e24a88aa825" -USER_EMAIL = "user@up42.com" -PASSWORD = "" - -DATA_PRODUCT_ID = "47dadb27-9532-4552-93a5-48f70a83eaef" - -ORDER_ID = "da2310a2-c7fb-42ed-bead-fb49ad862c67" -ASSET_ID = "363f89c1-3586-4b14-9a49-03a890c3b593" -ASSET_ORDER_ID = "22d0b8e9-b649-4971-8adc-1a5eac1fa6f3" -STAC_COLLECTION_ID = "e459db4c-3b9d-4aa1-8931-5df2517b49ba" - -URL_STAC_CATALOG = "https://api.up42.com/v2/assets/stac/" -URL_STAC_SEARCH = "https://api.up42.com/v2/assets/stac/search" - - -STAC_SEARCH_RESPONSE = { - "type": "FeatureCollection", - "features": [ - { - "assets": {"data": {"href": "https://api.up42.com/v2/assets/01ad657e-12f7-4046-a94c-abc90d86106a"}}, - "links": [ - { - "href": "https://api.up42.com/v2/assets/stac/collections/69ce89b4-fa35-4a1a-bcd8-1c2e5bbd2ee6/" - "items/e986e18a-0392-4b82-93c9-7a0af15846d0", - "rel": "self", - "type": "application/geo+json", - }, - { - "href": "https://api.up42.com/v2/assets/stac/collections/69ce89b4-fa35-4a1a-bcd8-1c2e5bbd2ee6", - "rel": "parent", - "type": "application/json", - }, - { - "href": "https://api.up42.com/v2/assets/stac/collections/69ce89b4-fa35-4a1a-bcd8-1c2e5bbd2ee6", - "rel": "collection", - "type": "application/json", - }, - { - "href": URL_STAC_CATALOG, - "rel": "root", - "type": "application/json", - "title": "UP42 Storage", - }, - ], - "stac_extensions": [ - "https://stac-extensions.github.io/projection/v1.0.0/schema.json", - "https://api.up42.com/stac-extensions/up42-product/v1.0.0/schema.json", - ], - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [52.4941111111112, 13.4025555555556], - [52.4941111111112, 13.4111666666667], - [52.4911111111112, 13.4111666666667], - [52.4911111111112, 13.4025555555556], - [52.4941111111112, 13.4025555555556], - [52.4941111111112, 13.4025555555556], - ] - ], - }, - "bbox": [ - 52.4911111111112, - 13.4025555555556, - 52.4941111111112, - 13.4111666666667, - ], - "properties": { - "up42-system:asset_id": ASSET_ID, - "gsd": 9.118863577837482, - "datetime": "2021-05-31T09:51:52.100000+00:00", - "platform": "SPOT-7", - "proj:epsg": 4326, - "end_datetime": "2021-05-31T09:51:52.100000+00:00", - "eo:cloud_cover": 0.0, - "start_datetime": "2021-05-31T09:51:52.100000+00:00", - "up42-system:workspace_id": "7d1cf222-1fa7-468c-a93a-3e3188875997", - "up42-product:collection_name": "Collection No 1", - }, - "type": "Feature", - "stac_version": "1.0.0", - "id": "e986e18a-0392-4b82-93c9-7a0af15846d0", - "collection": STAC_COLLECTION_ID, - } - ], -} - - -STAC_CATALOG_RESPONSE = { - "conformsTo": [ - "https://api.stacspec.org/v1.0.0-rc.1/item-search#sort", - "https://api.stacspec.org/v1.0.0-rc.1/collections", - "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter", - "http://www.opengis.net/spec/ogcapi-features-4/1.0/conf/simpletx", - "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:basic-cql", - "https://api.stacspec.org/v1.0.0-rc.1/item-search", - "https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features/extensions/transaction", - "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:cql-text", - "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter", - "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter", - "https://api.stacspec.org/v1.0.0-rc.1/core", - "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core", - "https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features", - "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson", - "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30", - ], - "links": [ - { - "href": URL_STAC_CATALOG, - "rel": "self", - "type": "application/json", - }, - { - "href": URL_STAC_CATALOG, - "rel": "root", - "type": "application/json", - }, - { - "href": "https://api.up42.com/v2/assets/stac/collections", - "rel": "data", - "type": "application/json", - }, - { - "href": URL_STAC_SEARCH, - "rel": "search", - "type": "application/json", - "method": "POST", - }, - ], - "stac_extensions": [], - "title": "UP42 Storage", - "description": "UP42 Storage STAC API", - "stac_version": "1.0.0", - "id": "up42-storage", - "type": "Catalog", -} diff --git a/tests/http/test_client.py b/tests/http/test_client.py index 259f181d7..dfe5ccd8f 100644 --- a/tests/http/test_client.py +++ b/tests/http/test_client.py @@ -3,7 +3,7 @@ import pytest -from tests.fixtures import fixtures_globals as constants +from tests import constants from up42.http import client, config SETTINGS = {"some": "settings"} diff --git a/tests/test_asset.py b/tests/test_asset.py index 551848021..53628060b 100644 --- a/tests/test_asset.py +++ b/tests/test_asset.py @@ -6,19 +6,90 @@ import pytest import requests_mock as req_mock +from tests import constants, helpers from up42 import asset -from . import helpers -from .fixtures import fixtures_globals as constants - +ASSET_ID = "363f89c1-3586-4b14-9a49-03a890c3b593" DOWNLOAD_URL = f"{constants.API_HOST}/abcdef.tgz" STAC_FILE = "stac_file.tiff" STAC_ASSET_URL = "https://example.com/some-random-path" STAC_ASSET_HREF = f"{constants.API_HOST}/v2/assets/stac-id" +STAC_COLLECTION_ID = "e459db4c-3b9d-4aa1-8931-5df2517b49ba" +STAC_SEARCH_RESPONSE = { + "type": "FeatureCollection", + "features": [ + { + "assets": {"data": {"href": "https://api.up42.com/v2/assets/01ad657e-12f7-4046-a94c-abc90d86106a"}}, + "links": [ + { + "href": "https://api.up42.com/v2/assets/stac/collections/69ce89b4-fa35-4a1a-bcd8-1c2e5bbd2ee6/" + "items/e986e18a-0392-4b82-93c9-7a0af15846d0", + "rel": "self", + "type": "application/geo+json", + }, + { + "href": "https://api.up42.com/v2/assets/stac/collections/69ce89b4-fa35-4a1a-bcd8-1c2e5bbd2ee6", + "rel": "parent", + "type": "application/json", + }, + { + "href": "https://api.up42.com/v2/assets/stac/collections/69ce89b4-fa35-4a1a-bcd8-1c2e5bbd2ee6", + "rel": "collection", + "type": "application/json", + }, + { + "href": constants.URL_STAC_CATALOG, + "rel": "root", + "type": "application/json", + "title": "UP42 Storage", + }, + ], + "stac_extensions": [ + "https://stac-extensions.github.io/projection/v1.0.0/schema.json", + "https://api.up42.com/stac-extensions/up42-product/v1.0.0/schema.json", + ], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [52.4941111111112, 13.4025555555556], + [52.4941111111112, 13.4111666666667], + [52.4911111111112, 13.4111666666667], + [52.4911111111112, 13.4025555555556], + [52.4941111111112, 13.4025555555556], + [52.4941111111112, 13.4025555555556], + ] + ], + }, + "bbox": [ + 52.4911111111112, + 13.4025555555556, + 52.4941111111112, + 13.4111666666667, + ], + "properties": { + "up42-system:asset_id": ASSET_ID, + "gsd": 9.118863577837482, + "datetime": "2021-05-31T09:51:52.100000+00:00", + "platform": "SPOT-7", + "proj:epsg": 4326, + "end_datetime": "2021-05-31T09:51:52.100000+00:00", + "eo:cloud_cover": 0.0, + "start_datetime": "2021-05-31T09:51:52.100000+00:00", + "up42-system:workspace_id": "7d1cf222-1fa7-468c-a93a-3e3188875997", + "up42-product:collection_name": "Collection No 1", + }, + "type": "Feature", + "stac_version": "1.0.0", + "id": "e986e18a-0392-4b82-93c9-7a0af15846d0", + "collection": STAC_COLLECTION_ID, + } + ], +} class TestAsset: - asset_info = {"id": constants.ASSET_ID, "other": "data"} + asset_info = {"id": ASSET_ID, "other": "data"} @pytest.fixture(params=["output_dir", "no_output_dir"]) def output_directory(self, request, tmp_path) -> Optional[str]: @@ -45,9 +116,9 @@ def test_should_delegate_repr_to_info(self): assert repr(asset.Asset(asset_info=self.asset_info)) == repr(self.asset_info) def test_should_initialize(self, requests_mock: req_mock.Mocker): - url = f"{constants.API_HOST}/v2/assets/{constants.ASSET_ID}/metadata" + url = f"{constants.API_HOST}/v2/assets/{ASSET_ID}/metadata" requests_mock.get(url=url, json=self.asset_info) - assert asset.Asset(asset_id=constants.ASSET_ID).info == self.asset_info + assert asset.Asset(asset_id=ASSET_ID).info == self.asset_info def test_should_initialize_with_info_provided(self): assert asset.Asset(asset_info=self.asset_info).info == self.asset_info @@ -61,8 +132,8 @@ def test_should_initialize_with_info_provided(self): "Either asset_id or asset_info should be provided in the constructor.", ), ( - constants.ASSET_ID, - {"id": constants.ASSET_ID}, + ASSET_ID, + {"id": ASSET_ID}, "asset_id and asset_info cannot be provided simultaneously.", ), ], @@ -83,12 +154,12 @@ def test_should_download_expected_files( output_directory: Optional[str], asset_files: set[str], ): - url = f"{constants.API_HOST}/v2/assets/{constants.ASSET_ID}/metadata" + url = f"{constants.API_HOST}/v2/assets/{ASSET_ID}/metadata" unpacking = len(asset_files) > 1 requests_mock.get(url=url, json=self.asset_info) - asset_obj = asset.Asset(asset_id=constants.ASSET_ID) + asset_obj = asset.Asset(asset_id=ASSET_ID) requests_mock.post( - url=f"{constants.API_HOST}/v2/assets/{constants.ASSET_ID}/download-url", + url=f"{constants.API_HOST}/v2/assets/{ASSET_ID}/download-url", json={"url": DOWNLOAD_URL}, ) downloaded_files = asset_obj.download(output_directory, unpacking=unpacking) @@ -97,9 +168,9 @@ def test_should_download_expected_files( assert all(path.exists() for path in paths) def test_get_stac_download_url(self, requests_mock: req_mock.Mocker): - url = f"{constants.API_HOST}/v2/assets/{constants.ASSET_ID}/metadata" + url = f"{constants.API_HOST}/v2/assets/{ASSET_ID}/metadata" requests_mock.get(url=url, json=self.asset_info) - asset_obj = asset.Asset(asset_id=constants.ASSET_ID) + asset_obj = asset.Asset(asset_id=ASSET_ID) requests_mock.post( url=f"{STAC_ASSET_HREF}/download-url", json={"url": STAC_ASSET_URL}, @@ -130,9 +201,9 @@ def test_should_download_stac_asset( stac_url: str, stac_file: str, ): - url = f"{constants.API_HOST}/v2/assets/{constants.ASSET_ID}/metadata" + url = f"{constants.API_HOST}/v2/assets/{ASSET_ID}/metadata" requests_mock.get(url=url, json=self.asset_info) - asset_obj = asset.Asset(asset_id=constants.ASSET_ID) + asset_obj = asset.Asset(asset_id=ASSET_ID) content = b"some-content" requests_mock.get(url=stac_url, content=content) requests_mock.post( @@ -149,16 +220,16 @@ def test_should_get_stac_items_with_retries(self, requests_mock: req_mock.Mocker requests_mock.get(constants.URL_STAC_CATALOG, json=constants.STAC_CATALOG_RESPONSE) requests_mock.post( constants.URL_STAC_SEARCH, - [{"status_code": 401}, {"json": constants.STAC_SEARCH_RESPONSE}], + [{"status_code": 401}, {"json": STAC_SEARCH_RESPONSE}], ) - asset_obj = asset.Asset(asset_info={"id": constants.ASSET_ID}) - expected = pystac.ItemCollection.from_dict(constants.STAC_SEARCH_RESPONSE) + asset_obj = asset.Asset(asset_info={"id": ASSET_ID}) + expected = pystac.ItemCollection.from_dict(STAC_SEARCH_RESPONSE) assert asset_obj.stac_items.to_dict() == expected.to_dict() def test_fails_to_get_stac_items_after_retries(self, requests_mock: req_mock.Mocker): requests_mock.get(constants.URL_STAC_CATALOG, json=constants.STAC_CATALOG_RESPONSE) requests_mock.post(constants.URL_STAC_SEARCH, status_code=401) - asset_obj = asset.Asset(asset_info={"id": constants.ASSET_ID}) + asset_obj = asset.Asset(asset_info={"id": ASSET_ID}) with pytest.raises(ValueError): _ = asset_obj.stac_items @@ -166,12 +237,12 @@ def test_should_get_stac_info_with_retries(self, requests_mock: req_mock.Mocker) requests_mock.get(constants.URL_STAC_CATALOG, json=constants.STAC_CATALOG_RESPONSE) requests_mock.post( constants.URL_STAC_SEARCH, - [{"status_code": 401}, {"json": constants.STAC_SEARCH_RESPONSE}], + [{"status_code": 401}, {"json": STAC_SEARCH_RESPONSE}], ) expected = pystac.Collection( id="up42-storage", description="UP42 Storage STAC API", - extra_fields={"up42-system:asset_id": constants.ASSET_ID}, + extra_fields={"up42-system:asset_id": ASSET_ID}, extent=pystac.Extent( spatial=pystac.SpatialExtent(bboxes=[[1.0, 2.0, 3.0, 4.0]]), temporal=pystac.TemporalExtent(intervals=[[datetime.datetime.now(), None]]), @@ -186,10 +257,10 @@ def test_should_get_stac_info_with_retries(self, requests_mock: req_mock.Mocker) ) ) requests_mock.get( - url=f"{constants.API_HOST}/v2/assets/stac/collections/{constants.STAC_COLLECTION_ID}", + url=f"{constants.API_HOST}/v2/assets/stac/collections/{STAC_COLLECTION_ID}", json=expected.to_dict(), ) - asset_obj = asset.Asset(asset_info={"id": constants.ASSET_ID}) + asset_obj = asset.Asset(asset_info={"id": ASSET_ID}) assert asset_obj.stac_info.to_dict() == expected.to_dict() @pytest.mark.parametrize( @@ -202,13 +273,13 @@ def test_should_get_stac_info_with_retries(self, requests_mock: req_mock.Mocker) def test_fails_to_get_stac_info_after_retries(self, requests_mock: req_mock.Mocker, response: dict): requests_mock.get(constants.URL_STAC_CATALOG, json=constants.STAC_CATALOG_RESPONSE) requests_mock.post(constants.URL_STAC_SEARCH, [response]) - asset_obj = asset.Asset(asset_info={"id": constants.ASSET_ID}) + asset_obj = asset.Asset(asset_info={"id": ASSET_ID}) with pytest.raises(Exception): _ = asset_obj.stac_info class TestAssetUpdateMetadata: - asset_info = {"id": constants.ASSET_ID, "title": "title", "tags": ["tag1"]} - endpoint_url = f"{constants.API_HOST}/v2/assets/{constants.ASSET_ID}/metadata" + asset_info = {"id": ASSET_ID, "title": "title", "tags": ["tag1"]} + endpoint_url = f"{constants.API_HOST}/v2/assets/{ASSET_ID}/metadata" @pytest.mark.parametrize("title", [None, "new-title"]) @pytest.mark.parametrize("tags", [None, [], ["tag1", "tag2"]]) diff --git a/tests/test_auth.py b/tests/test_auth.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/test_base.py b/tests/test_base.py index a1414ce08..7c1d04bc2 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -5,10 +5,10 @@ import pytest import requests_mock as req_mock +from tests import constants from up42 import base -from .fixtures import fixtures_globals as constants - +TOKEN_ENDPOINT = "https://auth.up42.com/realms/public/protocol/openid-connect/token" USER_INFO_ENDPOINT = "https://auth.up42.com/realms/public/protocol/openid-connect/userinfo" @@ -23,14 +23,8 @@ def test_fails_to_provide_properties_if_not_authenticated(self): _ = base.workspace.session def test_should_authenticate(self, requests_mock): - requests_mock.post( - constants.TOKEN_ENDPOINT, - json={"access_token": constants.TOKEN, "expires_in": 5 * 60}, - ) - requests_mock.get( - url=USER_INFO_ENDPOINT, - json={"sub": constants.WORKSPACE_ID}, - ) + requests_mock.post(TOKEN_ENDPOINT, json={"access_token": constants.TOKEN, "expires_in": 5 * 60}) + requests_mock.get(url=USER_INFO_ENDPOINT, json={"sub": constants.WORKSPACE_ID}) base.workspace.authenticate(username=constants.USER_EMAIL, password=constants.PASSWORD) assert base.workspace.id == constants.WORKSPACE_ID diff --git a/tests/test_catalog.py b/tests/test_catalog.py index 2cd70ce10..ae2185fc2 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -9,11 +9,9 @@ import requests_mock as req_mock import shapely # type: ignore +from tests import constants, helpers from up42 import catalog, glossary, order -from . import helpers -from .fixtures import fixtures_globals as constants - PHR = "phr" SIMPLE_BOX = shapely.box(0, 0, 1, 1).__geo_interface__ START_DATE = "2014-01-01" diff --git a/tests/test_glossary.py b/tests/test_glossary.py index b047a82df..6664feb09 100644 --- a/tests/test_glossary.py +++ b/tests/test_glossary.py @@ -4,7 +4,7 @@ import pytest import requests_mock as req_mock -from tests.fixtures import fixtures_globals as constants +from tests import constants from up42 import glossary, utils DATA_PRODUCT = glossary.DataProduct( diff --git a/tests/test_initialization.py b/tests/test_initialization.py index 01e9b2409..a4c21c199 100644 --- a/tests/test_initialization.py +++ b/tests/test_initialization.py @@ -1,10 +1,11 @@ +import uuid + import requests_mock as req_mock import up42 +from tests import constants from up42 import catalog, storage, tasking -from .fixtures import fixtures_globals as constants - def test_should_initialize_objects(requests_mock: req_mock.Mocker): catalog_obj = up42.initialize_catalog() @@ -20,10 +21,12 @@ def test_should_initialize_objects(requests_mock: req_mock.Mocker): order_obj = up42.initialize_order(order_id=constants.ORDER_ID) assert order_obj.info == order_info - asset_url = f"{constants.API_HOST}/v2/assets/{constants.ASSET_ID}/metadata" - asset_info = {"id": constants.ASSET_ID, "other": "data"} + asset_id = str(uuid.uuid4()) + + asset_url = f"{constants.API_HOST}/v2/assets/{asset_id}/metadata" + asset_info = {"id": asset_id, "other": "data"} requests_mock.get(url=asset_url, json=asset_info) - asset_obj = up42.initialize_asset(asset_id=constants.ASSET_ID) + asset_obj = up42.initialize_asset(asset_id=asset_id) assert asset_obj.info == asset_info result = up42.initialize_tasking() diff --git a/tests/test_order.py b/tests/test_order.py index 2a7ea794b..fbc9fcd04 100644 --- a/tests/test_order.py +++ b/tests/test_order.py @@ -1,10 +1,10 @@ import pytest import requests_mock as req_mock +from tests import constants from up42 import asset, order -from .fixtures import fixtures_globals as constants - +ASSET_ORDER_ID = "22d0b8e9-b649-4971-8adc-1a5eac1fa6f3" ORDER_URL = f"{constants.API_HOST}/v2/orders/{constants.ORDER_ID}" ORDER_PLACEMENT_URL = f"{constants.API_HOST}/v2/orders?workspaceId={constants.WORKSPACE_ID}" @@ -94,7 +94,7 @@ def test_should_get_assets_if_valid(self, requests_mock: req_mock.Mocker, status asset_info = { "content": [ { - "id": constants.ASSET_ORDER_ID, + "id": ASSET_ORDER_ID, } ], "totalPages": 1, @@ -103,7 +103,7 @@ def test_should_get_assets_if_valid(self, requests_mock: req_mock.Mocker, status order_obj = order.Order(order_id=constants.ORDER_ID) (asset_obj,) = order_obj.get_assets() assert isinstance(asset_obj, asset.Asset) - assert asset_obj.asset_id == constants.ASSET_ORDER_ID + assert asset_obj.asset_id == ASSET_ORDER_ID @pytest.mark.parametrize( "status", diff --git a/tests/test_processing.py b/tests/test_processing.py index 1fc2c80df..1230aee70 100644 --- a/tests/test_processing.py +++ b/tests/test_processing.py @@ -11,8 +11,7 @@ import requests import requests_mock as req_mock -from tests import helpers -from tests.fixtures import fixtures_globals as constants +from tests import constants, helpers from up42 import processing, utils PROCESS_ID = "process-id" diff --git a/tests/test_processing_templates.py b/tests/test_processing_templates.py index bdd21cd8e..d7b5c0ffb 100644 --- a/tests/test_processing_templates.py +++ b/tests/test_processing_templates.py @@ -5,7 +5,7 @@ import pystac import pytest -from tests.fixtures import fixtures_globals as constants +from tests import constants from up42 import processing from up42 import processing_templates as templates diff --git a/tests/test_storage.py b/tests/test_storage.py index 21d00f128..6b6716b19 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -6,10 +6,9 @@ import pytest import requests_mock as req_mock +from tests import constants from up42 import asset, order, storage, utils -from .fixtures import fixtures_globals as constants - class TestStorage: @pytest.mark.parametrize("limit", [10, None]) diff --git a/tests/test_tasking.py b/tests/test_tasking.py index ee91457ee..01ef6ca19 100644 --- a/tests/test_tasking.py +++ b/tests/test_tasking.py @@ -4,11 +4,9 @@ import pytest import requests_mock as req_mock +from tests import constants, helpers from up42 import tasking -from . import helpers -from .fixtures import fixtures_globals as constants - ACQ_START = "2014-01-01T00:00:00" ACQ_END = "2022-12-31T23:59:59" ORDER_NAME = "order-name" diff --git a/tests/test_utils.py b/tests/test_utils.py index 93d61cdc7..b229616d6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -11,10 +11,9 @@ from dateutil import parser from shapely import geometry # type: ignore +from tests import constants from up42 import utils -from .fixtures import fixtures_globals as constants - POLY = geometry.Polygon([(0, 0), (1, 1), (1, 0)]) diff --git a/tests/test_webhooks.py b/tests/test_webhooks.py index cc15c44a2..09d5118de 100644 --- a/tests/test_webhooks.py +++ b/tests/test_webhooks.py @@ -6,10 +6,9 @@ import pytest import requests_mock as req_mock +from tests import constants from up42 import webhooks -from .fixtures import fixtures_globals as constants - WEBHOOK_ID = str(uuid.uuid4()) HOOKS_URL = f"{constants.API_HOST}/workspaces/{constants.WORKSPACE_ID}/webhooks" HOOK_URL = f"{HOOKS_URL}/{WEBHOOK_ID}"