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

fix: round_trip validation issues #159

Merged
merged 1 commit into from
Sep 23, 2024
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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies = [
'pydantic>=2.7,<2.9',
'pydantic-settings>=2.0',
'aind-data-schema>=1.0.0',
'aind-data-transfer-models==0.8.4'
'aind-data-transfer-models==0.8.5'
]

[project.optional-dependencies]
Expand Down
49 changes: 48 additions & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ def test_submit_v1_jobs_200_trigger_capsule_configs(
self,
mock_post: MagicMock,
):
"""Tests suubmission when user adds trigger_capsule_configs"""
"""Tests submission when user adds trigger_capsule_configs"""

mock_response = Response()
mock_response.status_code = 200
Expand Down Expand Up @@ -1658,6 +1658,53 @@ def test_submit_v1_jobs_200_trigger_capsule_configs(
)
self.assertEqual(200, submit_job_response.status_code)

@patch.dict(os.environ, EXAMPLE_ENV_VAR1, clear=True)
@patch("requests.post")
def test_submit_v1_jobs_200_basic_serialization(
self,
mock_post: MagicMock,
):
"""Tests submission when user posts standard pydantic json"""

mock_response = Response()
mock_response.status_code = 200
mock_response._content = json.dumps({"message": "sent"}).encode(
"utf-8"
)
mock_post.return_value = mock_response
ephys_source_dir = PurePosixPath("shared_drive/ephys_data/690165")

s3_bucket = "private"
subject_id = "690165"
acq_datetime = datetime(2024, 2, 19, 11, 25, 17)
platform = Platform.ECEPHYS

ephys_config = ModalityConfigs(
modality=Modality.ECEPHYS,
source=ephys_source_dir,
)
project_name = "Ephys Platform"

upload_job_configs = BasicUploadJobConfigs(
project_name=project_name,
s3_bucket=s3_bucket,
platform=platform,
subject_id=subject_id,
acq_datetime=acq_datetime,
modalities=[ephys_config],
)

upload_jobs = [upload_job_configs]
submit_request = SubmitJobRequest(upload_jobs=upload_jobs)

post_request_content = json.loads(submit_request.model_dump_json())

with TestClient(app) as client:
submit_job_response = client.post(
url="/api/v1/submit_jobs", json=post_request_content
)
self.assertEqual(200, submit_job_response.status_code)


if __name__ == "__main__":
unittest.main()
Loading