Skip to content

Commit

Permalink
improving tests (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollman authored Dec 16, 2024
1 parent 7c87ed8 commit 5c51e18
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test_jsonclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_upload_state_json(myclient):
state_id = myclient.state.upload_state_json(json_state)
assert state_id == 1234

## test the get_state_json method
# test the get_state_json method
url = f"{global_server}/nglstate/api/v1/{state_id}"
responses.add(responses.GET, url=url, json=json_state, status=200)
state = myclient.state.get_state_json(state_id)
Expand Down
43 changes: 43 additions & 0 deletions tests/test_materialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,3 +851,46 @@ def mock_get_root_timestamps(self, root_ids):
)
new_xyz = np.vstack(df.ctr_pt_position.values)
assert np.all(new_xyz == orig_xyz * [4, 4, 40])


@responses.activate
def test_get_view_metadata(myclient):
datastack_name = "test_datastack"
view_name = "test_view"
materialization_version = 1

url = f"{datastack_dict['local_server']}/materialize/api/v3/datastack/{datastack_name}/version/{materialization_version}/views/{view_name}/metadata"
# Mock the response
mock_response = {"metadata_key": "metadata_value"}
responses.add(responses.GET, url=url, json=mock_response, status=200)

# Call the method
result = myclient.materialize.get_view_metadata(
view_name, materialization_version, datastack_name
)

# Verify the result
assert result == mock_response
assert "metadata_key" in result
assert result["metadata_key"] == "metadata_value"


@responses.activate
def test_get_unique_string_values(myclient):
datastack_name = "test_datastack"
table_name = "test_table"

url = f"{datastack_dict['local_server']}/materialize/api/v3/datastack/{datastack_name}/table/{table_name}/unique_string_values"
# Mock the response
mock_response = {"column1": ["value1", "value2"], "column2": ["value3", "value4"]}
responses.add(responses.GET, url=url, json=mock_response, status=200)

# Call the method
result = myclient.materialize.get_unique_string_values(table_name, datastack_name)

# Verify the result
assert result == mock_response
assert "column1" in result
assert "column2" in result
assert result["column1"] == ["value1", "value2"]
assert result["column2"] == ["value3", "value4"]

0 comments on commit 5c51e18

Please sign in to comment.