def test_fetch_item(self) -> None: collection = Collection.fetch('ref_african_crops_kenya_02_source') item = collection.fetch_item( 'ref_african_crops_kenya_02_tile_02_20190721') assert isinstance(item, pystac.item.Item) assert len(item.assets) == 13
def test_get_items_error(self, source_collection): collection = Collection.fetch('bigearthnet_v1_source') with pytest.raises(NotImplementedError) as excinfo: collection.get_items() assert 'For performance reasons, the get_items method has not been implemented for Collection instances. Please ' \ 'use the Collection.download method to download Collection assets.' == str(excinfo.value)
def test_get_registry_url_no_doi(self) -> None: # Get the example collection as a dict and remove the sci:doi property collection_dict: Dict[str, Any] = Collection.fetch( 'ref_african_crops_kenya_02_labels').to_dict() collection_dict.pop('sci:doi', None) collection: Collection = Collection.from_dict(collection_dict) assert collection.registry_url is None
def test_fetch_passes_session_to_instance(self, requests_mock: "Mocker_Type", root_url: str) -> None: collection_id = 'bigearthnet_v1_source' collection_url = urljoin(root_url, f'collections/{collection_id}') example_collection = Path( __file__).parent / "data" / "bigearthnet_v1_source.json" with open(example_collection) as src: requests_mock.get(collection_url, json=json.load(src)) collection = Collection.fetch(collection_id, profile="__anonymous__") assert collection.session_kwargs.get("profile") == "__anonymous__"
def test_fetch_anonymously_has_no_key(self, requests_mock: "Mocker_Type", root_url: str) -> None: collection_id = 'bigearthnet_v1_source' url = urljoin(root_url, f'collections/{collection_id}') example_collection = Path( __file__).parent / "data" / "bigearthnet_v1_source.json" with open(example_collection) as src: requests_mock.get(url, json=json.load(src)) _ = Collection.fetch(collection_id, profile="__anonymous__") history = requests_mock.request_history actual_url = history[0].url qs = parse_qs(urlsplit(actual_url).query) assert "key" not in qs
def test_download_archive(self, source_collection_archive, source_collection, tmp_path): collection = Collection.fetch('bigearthnet_v1_source') output_path = collection.download(output_dir=tmp_path) assert output_path == tmp_path / 'bigearthnet_v1_source.tar.gz' assert output_path.exists()
def test_fetch_item(self, source_collection, source_collection_item): collection = Collection.fetch('bigearthnet_v1_source') item = collection.fetch_item('bigearthnet_v1_source_S2A_MSIL2A_20180526T100031_65_62') assert isinstance(item, pystac.Item) assert len(item.assets) == 13
def test_fetch_collection(self, source_collection): collection = Collection.fetch('bigearthnet_v1_source') assert isinstance(collection, Collection) assert collection.description == 'BigEarthNet v1.0'
def test_download_archive(self, tmp_path: "Path_Type") -> None: collection = Collection.fetch('ref_african_crops_kenya_02_labels') output_path = collection.download(output_dir=tmp_path) assert output_path == tmp_path / 'ref_african_crops_kenya_02_labels.tar.gz' assert output_path.exists()
def test_get_archive_size(self) -> None: collection = Collection.fetch('bigearthnet_v1_labels') assert collection.archive_size == 173029030
def test_get_registry_url(self) -> None: collection = Collection.fetch('ref_african_crops_kenya_02_labels') assert collection.registry_url == 'https://registry.mlhub.earth/10.34911/rdnt.dw605x'