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

Add tests targeting core functionality of /data_objects/study/{study_id} endpoint #849

Conversation

eecavanna
Copy link
Collaborator

@eecavanna eecavanna commented Dec 18, 2024

Note

This branch is under construction.

In this branch, I implemented some pytest tests that exercise the core functionality of the /data_objects/study/{study_id} endpoint.

Details

The tests do not currently exercise all of the core functionality of that endpoint. I plan to hand this branch off to someone else to fill in the gaps (by following the "example" tests I have added here).

Related issue(s)

Eventually, this PR will fix #725.

Related subsystem(s)

  • Runtime API (except the Minter)
  • Minter
  • Dagster
  • Project documentation (in the docs directory)
  • Translators (metadata ingest pipelines)
  • MongoDB migrations
  • Other

Testing

  • I tested these changes (explain below)
  • I did not test these changes

I tested these changes by running $ make test-run on this branch, where the test-run Make target has been redefined locally as:

test-run:
	docker compose --file docker-compose.test.yml run test tests/test_api/test_endpoints.py

Documentation

  • I have not checked for relevant documentation yet (e.g. in the docs directory)
  • I have updated all relevant documentation so it will remain accurate
  • Other (explain below)

Maintainability

  • Every Python function I defined includes a docstring (test functions are exempt from this)
  • Every Python function parameter I introduced includes a type hint (e.g. study_id: str)
  • All "to do" or "fix me" Python comments I added begin with either # TODO or # FIXME
  • I used black to format all the Python files I created/modified
  • The PR title is in the imperative mood (e.g. "Do X") and not the declarative mood (e.g. "Does X" or "Did X")

@eecavanna
Copy link
Collaborator Author

Hi @sujaypatil96, I created this branch on which I've written some tests that target some of the core functionality of the /data_objects/study/{study_id} endpoint. I'll bring this up during this week's referential integrity squad meeting.

@dwinston dwinston marked this pull request as ready for review December 19, 2024 19:08
@sujaypatil96
Copy link
Collaborator

sujaypatil96 commented Dec 19, 2024

Mermaid diagram describing instance relationships in the example/scenario used in test_find_data_objects_for_study_having_one():

graph LR
    nmdc:bsm-11-6zd5nb38 -- "associated_studies" --> nmdc:sty-11-r2h77870
    nmdc:bsm-11-6zd5nb38 -- "has_input" --> nmdc:omprc-11-nmtj1g51
    nmdc:omprc-11-nmtj1g51 -- "was_informed_by" --> nmdc:wfmsa-11-fqq66x60.1
    nmdc:wfmsa-11-fqq66x60.1 -- "has_output" --> nmdc:dobj-11-cpv4y420
Loading

@dwinston
Copy link
Collaborator

@sujaypatil96 I think our "setup" is incomplete. It seems like there needs to be a workflow_execution_set entity for GET /data_objects/study/{study_id} to find properly.

@sujaypatil96
Copy link
Collaborator

@dwinston yes you're right! This is what the workflow_execution_set record would look like:

workflow_execution_dict =  {"id" : "nmdc:wfmsa-11-fqq66x60.1",
    "was_informed_by" : "nmdc:omprc-11-nmtj1g51",
    "has_input" : [
        "nmdc:bsm-11-6zd5nb38"
    ],
    "has_output" : [
        "nmdc:dobj-11-cpv4y420"
    ],
    "type" : "nmdc:MetagenomeSequencing"
}

@dwinston
Copy link
Collaborator

this is ready for review and merge.

Copy link
Collaborator

@sujaypatil96 sujaypatil96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a test case for the /data_objects/study/{study_id} endpoint in the test suite now. There's a mermaid diagram that captures the scenario we are simulating.

We're basically looking for an expected DataObject id in the response JSON for the /data_objects/study/{study_id} for a given study id and that works.

@sujaypatil96 sujaypatil96 merged commit 78f160f into main Dec 19, 2024
2 checks passed
@sujaypatil96 sujaypatil96 deleted the 725-core-functionality-of-data_objectsstudystudy_id-endpoint-is-not-being-tested branch December 19, 2024 20:57
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.

Core functionality of /data_objects/study/{study_id} endpoint is not being tested
3 participants