Skip to content

Commit

Permalink
chore: refactor to stop using the cache (#95)
Browse files Browse the repository at this point in the history
Not using any cache anymore
Always get the data on the fly
  • Loading branch information
renaudjester committed Aug 29, 2024
1 parent 84d2dd3 commit a22bdc8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 11 deletions.
9 changes: 3 additions & 6 deletions copernicusmarine/catalogue_parser/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ class WebApi(Enum):
)


class ServiceNotHandled(Exception):
...
class ServiceNotHandled(Exception): ...


# service formats
Expand Down Expand Up @@ -506,12 +505,10 @@ def filter_only_official_versions_and_parts(self):


# Errors
class DatasetVersionPartNotFound(Exception):
...
class DatasetVersionPartNotFound(Exception): ...


class DatasetVersionNotFound(Exception):
...
class DatasetVersionNotFound(Exception): ...


def dataset_version_part_not_found_exception(
Expand Down
6 changes: 2 additions & 4 deletions copernicusmarine/core_functions/credentials_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@
# TODO: handle cache of the credentials without cachier


class CredentialCannotBeNone(Exception):
...
class CredentialCannotBeNone(Exception): ...


class InvalidUsernameOrPassword(Exception):
...
class InvalidUsernameOrPassword(Exception): ...


def _load_credential_from_copernicus_marine_configuration_file(
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions tests/test_command_line_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,40 @@ def then_I_can_see_the_arco_geo_series_service_is_choosen(self):
in self.output.stderr
)

def test_subset_with_dataset_id_and_url(self):
command = [
"copernicusmarine",
"subset",
"-i",
"cmems_mod_arc_bgc_anfc_ecosmo_P1M-m",
"-u",
"https://nrt.cmems-du.eu/thredds/dodsC/METOFFICE-GLO-SST-L4-NRT-OBS-SST-V2",
"--variable",
"thetao",
]

self.output = execute_in_terminal(command)

assert self.output.returncode == 1
assert (
b"Must specify only one of 'dataset_url' or 'dataset_id' options"
) in self.output.stderr

def test_no_traceback_is_printed_on_dataset_url_error(self):
command = [
"copernicusmarine",
"get",
"--dataset-url",
"https://s3.waw3-1.cloudferro.com/mdl-arco-time-013/arco/"
"GLOBAL_ANALYSISFORECAST_PHY_XXXXXXX/"
"cmems_mod_glo_phy_anfc_0.083deg_P1D-m/2023",
]

self.output = execute_in_terminal(command)

assert self.output.returncode == 1
assert b"Traceback" not in self.output.stderr

def test_get_2023_08_original_files(self):
command = [
"copernicusmarine",
Expand Down Expand Up @@ -1180,6 +1214,20 @@ def test_subset_with_chunking(self, tmp_path):

assert self.output.returncode == 0

def test_dataset_url_suffix_path_are_used_as_filter(self):
command = [
"copernicusmarine",
"get",
"--dataset-url",
"https://s3.waw3-1.cloudferro.com/mdl-native-14/native/"
"GLOBAL_ANALYSISFORECAST_PHY_001_024/"
"cmems_mod_glo_phy_anfc_0.083deg_P1D-m_202406/2023/11",
]

self.output = execute_in_terminal(command)

assert b"Printed 20 out of 30 files" in self.output.stderr

def test_short_option_for_copernicus_marine_command_helper(self):
short_option_command = [
"copernicusmarine",
Expand Down

0 comments on commit a22bdc8

Please sign in to comment.