Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add some structured support for mocking the dataset-metadata endpoint #691

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<script type="text/javascript">
window.CELLXGENE = {};
window.CELLXGENE.API = {
prefix: `http://localhost:<%= CXG_SERVER_PORT %>${location.pathname}api/`,
prefix: `http://localhost:<%= CXG_SERVER_PORT %>${location.pathname}/api/`,
version: "v0.3/",
};
</script>
Expand Down
18 changes: 18 additions & 0 deletions dev_docs/developer_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ Puppeteer is a dependency for e2e tests, but it's not used for running Explorer

If you want to actually run e2e tests, then you'll need to set up Chromium to enable Puppeteer. [This blog post](https://broddin.be/2022/09/19/fixing-the-chromium-binary-is-not-available-for-arm64/) should show you how to do that on an M1/M2 machine.

### Mocking the dataset-metadata endpoint

The dataset-metadata endpoint requires using data-portal. A true local build would require running an instance of data-portal locally. An easier solution that works for most use cases is to just mock the response of dataset-metadata. To do this, you can update the `DatasetMetadataAPI` class in `server/app/api/v3.py` to:

```
class DatasetMetadataAPI(DatasetResource):
@cache_control(public=True, no_store=True, max_age=0)
@rest_get_dataset_explorer_location_data_adaptor
def get(self, data_adaptor):
with open("server/tests/fixtures/liver_dataset_metadata_response.json", "r") as file:
mock_response = json.load(file)

json_response = json.dumps(mock_response)
return Response(json_response, content_type='application/json')
```

Note that you'll need to `import json` and also add `Response` to the `flask` import. This will mock the expected response to the `liver.cxg` dataset that is in the `example-dataset/` directory. After updating the mock response, you can build the backend + frontend the same way you normally would.

### Before you request a PR review...

Please lint and format your code before requesting a PR review.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading