|
8 | 8 | from typing import List |
9 | 9 |
|
10 | 10 | from aind_data_schema.data_description import ( |
| 11 | + AnalysisDescription, |
11 | 12 | DataDescription, |
12 | 13 | DerivedDataDescription, |
13 | 14 | Funding, |
@@ -38,6 +39,7 @@ def setUpClass(cls): |
38 | 39 | BAD_NAME = "fizzbuzz" |
39 | 40 | BASIC_NAME = "ecephys_1234_3033-12-21_04-22-11" |
40 | 41 | DERIVED_NAME = "ecephys_1234_3033-12-21_04-22-11_spikesorted-ks25_2022-10-12_23-23-11" |
| 42 | + ANALYSIS_NAME = "project_analysis_3033-12-21_04-22-11" |
41 | 43 |
|
42 | 44 | def test_constructors(self): |
43 | 45 | """test building from component parts""" |
@@ -120,6 +122,59 @@ def test_constructors(self): |
120 | 122 | investigators=["Jane Smith"], |
121 | 123 | ) |
122 | 124 |
|
| 125 | + ad = AnalysisDescription( |
| 126 | + analysis_name="analysis", |
| 127 | + project_name="project", |
| 128 | + creation_time=dt, |
| 129 | + subject_id="1234", |
| 130 | + modality=[Modality.SPIM], |
| 131 | + platform="exaspim", |
| 132 | + institution=Institution.AIND, |
| 133 | + funding_source=[f], |
| 134 | + investigators=["Jane Smith"], |
| 135 | + ) |
| 136 | + |
| 137 | + self.assertEqual(ad.label, "project_analysis") |
| 138 | + |
| 139 | + with self.assertRaises(ValueError): |
| 140 | + AnalysisDescription( |
| 141 | + analysis_name="ana lysis", |
| 142 | + project_name="pro_ject", |
| 143 | + subject_id="1234", |
| 144 | + modality=[Modality.SPIM], |
| 145 | + platform="exaspim", |
| 146 | + creation_time=dt, |
| 147 | + institution=Institution.AIND, |
| 148 | + funding_source=[f], |
| 149 | + investigators=["Jane Smith"], |
| 150 | + ) |
| 151 | + |
| 152 | + with self.assertRaises(ValueError): |
| 153 | + AnalysisDescription( |
| 154 | + analysis_name="", |
| 155 | + project_name="project", |
| 156 | + subject_id="1234", |
| 157 | + modality=[Modality.SPIM], |
| 158 | + platform="exaspim", |
| 159 | + creation_time=dt, |
| 160 | + institution=Institution.AIND, |
| 161 | + funding_source=[f], |
| 162 | + investigators=["Jane Smith"], |
| 163 | + ) |
| 164 | + |
| 165 | + with self.assertRaises(ValueError): |
| 166 | + AnalysisDescription( |
| 167 | + analysis_name="analysis", |
| 168 | + project_name="", |
| 169 | + subject_id="1234", |
| 170 | + modality=[Modality.SPIM], |
| 171 | + platform="exaspim", |
| 172 | + creation_time=dt, |
| 173 | + institution=Institution.AIND, |
| 174 | + funding_source=[f], |
| 175 | + investigators=["Jane Smith"], |
| 176 | + ) |
| 177 | + |
123 | 178 | def test_round_trip(self): |
124 | 179 | """make sure we can round trip from json""" |
125 | 180 |
|
@@ -167,6 +222,14 @@ def test_parse_name(self): |
167 | 222 | with self.assertRaises(ValueError): |
168 | 223 | toks = DerivedDataDescription.parse_name(self.BAD_NAME) |
169 | 224 |
|
| 225 | + toks = AnalysisDescription.parse_name(self.ANALYSIS_NAME) |
| 226 | + assert toks["project_abbreviation"] == "project" |
| 227 | + assert toks["analysis_name"] == "analysis" |
| 228 | + assert toks["creation_time"] == datetime.datetime(3033, 12, 21, 4, 22, 11) |
| 229 | + |
| 230 | + with self.assertRaises(ValueError): |
| 231 | + toks = AnalysisDescription.parse_name(self.BAD_NAME) |
| 232 | + |
170 | 233 | def test_abbreviation_enums(self): |
171 | 234 | """Tests that BaseName enums can be constructed from abbreviations""" |
172 | 235 | # Tests that Modality constructed as expected |
|
0 commit comments