@@ -270,6 +270,70 @@ def test_cannot_create_experiment_that_keywords_has_wrong_combination4(client, s
270270 )
271271
272272
273+ def test_create_experiment_that_keyword_gene_ontology_has_valid_accession (client , setup_router_db ):
274+ valid_keyword = {
275+ "keywords" : [
276+ {
277+ "keyword" : {
278+ "key" : "Phenotypic Assay Mechanism" ,
279+ "value" : "Value" ,
280+ "accession" : "GO:1234567" ,
281+ "special" : False ,
282+ "description" : "Description" },
283+ },
284+ ],
285+ }
286+ experiment = {** TEST_MINIMAL_EXPERIMENT , ** valid_keyword }
287+ response = client .post ("/api/v1/experiments/" , json = experiment )
288+ assert response .status_code == 200
289+ response_data = response .json ()
290+ assert response_data ["keywords" ][0 ]["keyword" ]["key" ] == "Phenotypic Assay Mechanism"
291+ assert response_data ["keywords" ][0 ]["keyword" ]["value" ] == "Value"
292+ assert response_data ["keywords" ][0 ]["keyword" ]["accession" ] == "GO:1234567"
293+
294+
295+ def test_create_experiment_that_keyword_gene_ontology_is_other_without_accession (client , setup_router_db ):
296+ valid_keyword = {
297+ "keywords" : [
298+ {
299+ "keyword" : {
300+ "key" : "Phenotypic Assay Mechanism" ,
301+ "value" : "Other" ,
302+ "accession" : None ,
303+ "description" : "Description"
304+ },
305+ "description" : "Description" ,
306+ },
307+ ]
308+ }
309+ experiment = {** TEST_MINIMAL_EXPERIMENT , ** valid_keyword }
310+ response = client .post ("/api/v1/experiments/" , json = experiment )
311+ assert response .status_code == 200
312+ response_data = response .json ()
313+ assert response_data ["keywords" ][0 ]["keyword" ]["key" ] == "Phenotypic Assay Mechanism"
314+ assert response_data ["keywords" ][0 ]["keyword" ]["value" ] == "Other"
315+
316+
317+ def test_cannot_create_experiment_that_keyword_has_an_invalid_accession (client , setup_router_db ):
318+ invalid_keyword = {
319+ "keywords" : [
320+ {
321+ "keyword" : {
322+ "key" : "Phenotypic Assay Mechanism" ,
323+ "value" : "Value" ,
324+ "accession" : "invalid" ,
325+ "description" : "Description"
326+ },
327+ },
328+ ]
329+ }
330+ experiment = {** TEST_MINIMAL_EXPERIMENT , ** invalid_keyword }
331+ response = client .post ("/api/v1/experiments/" , json = experiment )
332+ assert response .status_code == 422
333+ response_data = response .json ()
334+ assert response_data ["detail" ][0 ]["msg" ] == "Invalid Gene Ontology accession."
335+
336+
273337def test_cannot_create_experiment_that_keyword_value_is_other_without_description (client , setup_router_db ):
274338 """
275339 Test src/mavedb/lib/validation/keywords.validate_description function
0 commit comments