@@ -131,3 +131,31 @@ def test_publish_study(self):
131131
132132 res = openml .study .delete_study (study_id )
133133 self .assertTrue (res )
134+
135+ def test_study_attach_illegal (self ):
136+ run_list = openml .runs .list_runs (size = 10 )
137+ self .assertEqual (len (run_list ), 10 )
138+ run_list_more = openml .runs .list_runs (size = 20 )
139+ self .assertEqual (len (run_list_more ), 20 )
140+
141+ study = openml .study .create_study (
142+ alias = None ,
143+ benchmark_suite = None ,
144+ name = 'study with illegal runs' ,
145+ description = 'none' ,
146+ run_ids = list (run_list .keys ())
147+ )
148+ study_id = study .publish ()
149+ study_original = openml .study .get_study (study_id )
150+
151+ with self .assertRaisesRegex (openml .exceptions .OpenMLServerException ,
152+ 'Problem attaching entities.' ):
153+ # run id does not exists
154+ openml .study .attach_to_study (study_id , [0 ])
155+
156+ with self .assertRaisesRegex (openml .exceptions .OpenMLServerException ,
157+ 'Problem attaching entities.' ):
158+ # some runs already attached
159+ openml .study .attach_to_study (study_id , list (run_list_more .keys ()))
160+ study_downloaded = openml .study .get_study (study_id )
161+ self .assertListEqual (study_original .runs , study_downloaded .runs )
0 commit comments