diff --git a/pyproject.toml b/pyproject.toml index fb7df6c..6869d59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dependencies = [ 'boto3', 'pydantic>=2.0,<2.9', 'pydantic-settings>=2.0', - 'aind-data-transfer-models==0.7.0' + 'aind-data-transfer-models==0.8.0' ] [project.optional-dependencies] diff --git a/tests/test_server.py b/tests/test_server.py index 15d81a4..8552202 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -18,6 +18,7 @@ SubmitJobRequest, V0036JobProperties, ) +from aind_data_transfer_models.trigger import TriggerConfigModel, ValidJobType from fastapi.responses import StreamingResponse from fastapi.testclient import TestClient from pydantic import SecretStr @@ -1604,6 +1605,59 @@ def test_submit_v1_jobs_200_session_settings_config_file( ) 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_trigger_capsule_configs( + self, + mock_post: MagicMock, + ): + """Tests suubmission when user adds trigger_capsule_configs""" + + 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 + + trigger_capsule_settings = TriggerConfigModel( + job_type=ValidJobType.RUN_GENERIC_PIPELINE, capsule_id="abc-123" + ) + 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], + trigger_capsule_configs=trigger_capsule_settings, + ) + + upload_jobs = [upload_job_configs] + submit_request = SubmitJobRequest(upload_jobs=upload_jobs) + + post_request_content = json.loads( + submit_request.model_dump_json(round_trip=True) + ) + + 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()