Skip to content

Jules - Dataset Test#13

Draft
s2t2 wants to merge 1 commit intocopybara_pushfrom
test/dataset
Draft

Jules - Dataset Test#13
s2t2 wants to merge 1 commit intocopybara_pushfrom
test/dataset

Conversation

@s2t2
Copy link
Owner

@s2t2 s2t2 commented May 31, 2025

I've added unit tests for SmartBuildingsDataset.

This commit introduces a comprehensive test suite for the SmartBuildingsDataset class in smart_control/dataset/dataset.py.

The tests cover the following functionalities:

  • Initialization (__init__):
    • Verifies that the download() method is called by default.
    • Verifies that download() is not called when download=False.
  • Data Downloading (download):
    • Mocks network requests and file operations to simulate successful downloads.
    • Tests handling of network errors (requests.exceptions.RequestException, requests.exceptions.HTTPError) during download.
  • Floorplan Retrieval (get_floorplan):
    • Tests successful loading of floorplan and device layout map data.
    • Mocks file system interactions (np.load, json.load).
    • Ensures ValueError is raised for invalid building names.
  • Building Data Retrieval (get_building_data):
    • Tests successful loading of building data and metadata.
    • Mocks file system interactions (np.load, pickle.load).
    • Verifies correct loading of additional metadata (device_infos, zone_infos) when not present in the primary metadata file.
    • Ensures ValueError is raised for invalid building or partition names.

The new test file is smart_control/dataset/dataset_test.py and includes 11 test cases in total, utilizing unittest.mock for isolating the class from external dependencies like network and file system.

This commit introduces a comprehensive test suite for the `SmartBuildingsDataset` class in `smart_control/dataset/dataset.py`.

The tests cover the following functionalities:
- Initialization (`__init__`):
    - Verifies that the `download()` method is called by default.
    - Verifies that `download()` is not called when `download=False`.
- Data Downloading (`download`):
    - Mocks network requests and file operations to simulate successful downloads.
    - Tests handling of network errors (`requests.exceptions.RequestException`, `requests.exceptions.HTTPError`) during download.
- Floorplan Retrieval (`get_floorplan`):
    - Tests successful loading of floorplan and device layout map data.
    - Mocks file system interactions (`np.load`, `json.load`).
    - Ensures `ValueError` is raised for invalid building names.
- Building Data Retrieval (`get_building_data`):
    - Tests successful loading of building data and metadata.
    - Mocks file system interactions (`np.load`, `pickle.load`).
    - Verifies correct loading of additional metadata (`device_infos`, `zone_infos`) when not present in the primary metadata file.
    - Ensures `ValueError` is raised for invalid building or partition names.

The new test file is `smart_control/dataset/dataset_test.py` and includes 11 test cases in total, utilizing `unittest.mock` for isolating the class from external dependencies like network and file system.
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.

1 participant