Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
b-yogesh committed Dec 10, 2024
1 parent 865ead4 commit 3e1b545
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/test_clms.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def setUp(self):
self.mock_path = "mockpath"

@patch("xcube_clms.clms.CLMS._fetch_all_datasets")
@patch("xcube_clms.preload.CLMSAPIToken")
@patch("xcube_clms.token_handler.CLMSAPIToken")
@patch("xcube_clms.preload.PreloadData")
def test_initialization(
self, mock_preload, mock_clms_api_token, mock_fetch_datasets
Expand Down Expand Up @@ -83,7 +83,7 @@ def test_initialization(

@patch("xcube_clms.clms.os.listdir")
@patch("xcube_clms.clms.CLMS._fetch_all_datasets")
@patch("xcube_clms.preload.CLMSAPIToken")
@patch("xcube_clms.token_handler.CLMSAPIToken")
@patch("xcube_clms.preload.PreloadData")
def test_open_data(
self,
Expand All @@ -101,7 +101,7 @@ def test_open_data(
mock_preload_instance = MagicMock()
mock_preload_instance._clms_api_token_instance = mock_token_instance
mock_preload_instance._api_token = "mocked_access_token"
mock_preload_instance.cache = {data_id: "file_id/"}
mock_preload_instance.view_cache.return_value = {data_id: "file_id/"}
mock_preload.return_value = mock_preload_instance

mock_os_listdir.return_value = ["file_id/"]
Expand All @@ -123,7 +123,7 @@ def test_open_data(
self.assertIsInstance(opened_data, xr.Dataset)

clms = CLMS(self.mock_url, self.mock_credentials, self.mock_path)
mock_preload_instance.cache = {}
mock_preload_instance.view_cache.return_value = {}
clms._preload_data = mock_preload_instance

with pytest.raises(
Expand All @@ -140,7 +140,7 @@ def test_open_data(
clms.open_data(data_id)

@patch("xcube_clms.clms.CLMS._fetch_all_datasets")
@patch("xcube_clms.preload.CLMSAPIToken")
@patch("xcube_clms.token_handler.CLMSAPIToken")
@patch("xcube_clms.preload.PreloadData")
def test_get_data_ids(
self,
Expand Down Expand Up @@ -200,7 +200,7 @@ def test_get_data_ids(
]

@patch("xcube_clms.clms.CLMS._fetch_all_datasets")
@patch("xcube_clms.preload.CLMSAPIToken")
@patch("xcube_clms.token_handler.CLMSAPIToken")
@patch("xcube_clms.preload.PreloadData")
@patch("xcube_clms.clms.is_valid_data_type")
@patch("xcube_clms.clms.CLMS._get_item")
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_has_data(

@patch("xcube_clms.clms.CLMS._access_item")
@patch("xcube_clms.clms.CLMS._fetch_all_datasets")
@patch("xcube_clms.preload.CLMSAPIToken")
@patch("xcube_clms.token_handler.CLMSAPIToken")
@patch("xcube_clms.preload.PreloadData")
def test_get_extent(
self, mock_preload, mock_clms_api_token, mock_fetch_datasets, mock_access_item
Expand Down Expand Up @@ -311,7 +311,7 @@ def test_get_extent(

clms = CLMS(self.mock_url, self.mock_credentials, self.mock_path)

assert (clms._get_extent("dataset1|file1")) == {
assert (clms.get_extent("dataset1|file1")) == {
"time_range": (None, None),
"crs": None,
}
Expand All @@ -324,13 +324,13 @@ def test_get_extent(
}
clms = CLMS(self.mock_url, self.mock_credentials, self.mock_path)

assert (clms._get_extent("dataset1|file1")) == {
assert (clms.get_extent("dataset1|file1")) == {
"time_range": ("01-12-2022", "01-12-2024"),
"crs": "WGS84",
}

@patch("xcube_clms.clms.CLMS._fetch_all_datasets")
@patch("xcube_clms.preload.CLMSAPIToken")
@patch("xcube_clms.token_handler.CLMSAPIToken")
@patch("xcube_clms.preload.PreloadData")
def test_create_data_ids(
self,
Expand Down Expand Up @@ -455,7 +455,7 @@ def test_fetch_all_datasets(

@patch("xcube_clms.clms.CLMS._get_item")
@patch("xcube_clms.clms.CLMS._fetch_all_datasets")
@patch("xcube_clms.preload.CLMSAPIToken")
@patch("xcube_clms.token_handler.CLMSAPIToken")
@patch("xcube_clms.preload.PreloadData")
def test_access_item(
self, mock_preload, mock_clms_api_token, mock_fetch_datasets, mock_get_item
Expand Down Expand Up @@ -504,7 +504,7 @@ def test_access_item(
assert item == expected_item

@patch("xcube_clms.clms.CLMS._fetch_all_datasets")
@patch("xcube_clms.preload.CLMSAPIToken")
@patch("xcube_clms.token_handler.CLMSAPIToken")
@patch("xcube_clms.preload.PreloadData")
def test_get_item(
self,
Expand Down

0 comments on commit 3e1b545

Please sign in to comment.