@@ -24,7 +24,9 @@ def setUp(self):
2424 self .url_update_curation = reverse (
2525 "update_curation" , kwargs = {"stable_id" : "G2P00004" }
2626 )
27-
27+ self .url_update_curation_2 = reverse (
28+ "update_curation" , kwargs = {"stable_id" : "G2P00010" }
29+ )
2830 self .url_update_invalid_curation = reverse (
2931 "update_curation" , kwargs = {"stable_id" : "G2P00123" }
3032 )
@@ -327,7 +329,6 @@ def test_update_curation_empty_locus(self):
327329 """
328330 self .login_user ()
329331
330- # Define the complex data structure
331332 curation_to_update = {
332333 "json_data" : {
333334 "allelic_requirement" : "" ,
@@ -358,7 +359,45 @@ def test_update_curation_empty_locus(self):
358359 self .assertEqual (response .status_code , 400 )
359360
360361 response_data = response .json ()
361- self .assertEqual (response_data ["error" ],"Invalid gene ''" )
362+ self .assertEqual (response_data ["error" ], "To save a draft, the minimum requirement is a locus entry. Please save this draft with locus information" )
363+
364+ def test_update_curation_invalid_locus (self ):
365+ """
366+ Test call to update curation endpoint with invalid locus field
367+ """
368+ self .login_user ()
369+
370+ curation_to_update = {
371+ "json_data" : {
372+ "allelic_requirement" : "" ,
373+ "confidence" : "" ,
374+ "cross_cutting_modifier" : [],
375+ "disease" : {"cross_references" : [], "disease_name" : "" },
376+ "locus" : "BAAT-21" ,
377+ "mechanism_evidence" : [],
378+ "mechanism_synopsis" : [],
379+ "molecular_mechanism" : {"name" : "" , "support" : "" },
380+ "panels" : [],
381+ "phenotypes" : [],
382+ "private_comment" : "" ,
383+ "public_comment" : "" ,
384+ "publications" : [],
385+ "session_name" : "test session" ,
386+ "variant_consequences" : [],
387+ "variant_descriptions" : [],
388+ "variant_types" : [],
389+ }
390+ }
391+
392+ response = self .client .put (
393+ self .url_update_curation ,
394+ curation_to_update ,
395+ content_type = "application/json" ,
396+ )
397+ self .assertEqual (response .status_code , 400 )
398+
399+ response_data = response .json ()
400+ self .assertEqual (response_data ["error" ], "Invalid gene 'BAAT-21'" )
362401
363402 def test_update_invalid_curation (self ):
364403 """
@@ -396,3 +435,49 @@ def test_update_invalid_curation(self):
396435 content_type = "application/json" ,
397436 )
398437 self .assertEqual (response .status_code , 404 )
438+
439+ def test_update_curation_duplicate (self ):
440+ """
441+ Test to update curation that would create a duplicate entry
442+ G2P ID G2P00010 has session name 'test session SRY', this test
443+ tries to update the json content to be the same as session 'test session' (G2P00004)
444+ """
445+ self .login_user ()
446+
447+ curation_to_update = {
448+ "json_data" : {
449+ "allelic_requirement" : "" ,
450+ "confidence" : "" ,
451+ "cross_cutting_modifier" : [],
452+ "disease" : {
453+ "cross_references" : [],
454+ "disease_name" : ""
455+ },
456+ "locus" : "CEP290" ,
457+ "mechanism_evidence" : [],
458+ "mechanism_synopsis" : [],
459+ "molecular_mechanism" : {
460+ "name" : "" ,
461+ "support" : ""
462+ },
463+ "panels" : [],
464+ "phenotypes" : [],
465+ "private_comment" : "" ,
466+ "public_comment" : "" ,
467+ "publications" : [],
468+ "session_name" : "test session SRY" ,
469+ "variant_consequences" : [],
470+ "variant_descriptions" : [],
471+ "variant_types" : []
472+ }
473+ }
474+
475+ response = self .client .put (
476+ self .url_update_curation_2 ,
477+ curation_to_update ,
478+ content_type = "application/json" ,
479+ )
480+ self .assertEqual (response .status_code , 400 )
481+
482+ response_data = response .json ()
483+ self .assertEqual (response_data ["error" ], "Data already under curation. Please check session 'test session'" )
0 commit comments