@@ -51,13 +51,13 @@ def _check_task(self, task):
5151 ['in_preparation' , 'active' , 'deactivated' ])
5252
5353 def test_list_tasks_by_type (self ):
54- tasks = openml .tasks .list_tasks_by_type (task_type_id = 3 )
54+ tasks = openml .tasks .list_tasks (task_type_id = 3 )
5555 self .assertGreaterEqual (len (tasks ), 300 )
5656 for task in tasks :
5757 self ._check_task (task )
5858
5959 def test_list_tasks_by_tag (self ):
60- tasks = openml .tasks .list_tasks_by_tag ( 'basic' )
60+ tasks = openml .tasks .list_tasks ( tag = 'basic' )
6161 self .assertGreaterEqual (len (tasks ), 57 )
6262 for task in tasks :
6363 self ._check_task (task )
@@ -68,6 +68,42 @@ def test_list_tasks(self):
6868 for task in tasks :
6969 self ._check_task (task )
7070
71+ def test_list_tasks_paginate (self ):
72+ size = 10
73+ max = 100
74+ for i in range (0 , max , size ):
75+ tasks = openml .tasks .list_tasks (offset = i , size = size )
76+ self .assertGreaterEqual (size , len (tasks ))
77+ for task in tasks :
78+ self .assertEqual (type (task ), dict )
79+ self .assertGreaterEqual (len (task ), 4 )
80+ self .assertIn ('tid' , task )
81+ self .assertIsInstance (task ['tid' ], int )
82+ self .assertIn ('did' , task )
83+ self .assertIsInstance (task ['did' ], int )
84+ self .assertIn ('status' , task )
85+ self .assertTrue (is_string (task ['status' ]))
86+ self .assertIn (task ['status' ], ['in_preparation' , 'active' , 'deactivated' ])
87+
88+ def test_list_tasks_per_type_paginate (self ):
89+ size = 10
90+ max = 100
91+ task_types = 5
92+ for j in range (1 ,task_types ):
93+ for i in range (0 , max , size ):
94+ tasks = openml .tasks .list_tasks (task_type_id = j , offset = i , size = size )
95+ self .assertGreaterEqual (size , len (tasks ))
96+ for task in tasks :
97+ self .assertEqual (type (task ), dict )
98+ self .assertGreaterEqual (len (task ), 4 )
99+ self .assertIn ('tid' , task )
100+ self .assertIsInstance (task ['tid' ], int )
101+ self .assertIn ('did' , task )
102+ self .assertIsInstance (task ['did' ], int )
103+ self .assertIn ('status' , task )
104+ self .assertTrue (is_string (task ['status' ]))
105+ self .assertIn (task ['status' ], ['in_preparation' , 'active' , 'deactivated' ])
106+
71107 def test__get_task (self ):
72108 openml .config .set_cache_directory (self .static_cache_dir )
73109 task = openml .tasks .get_task (1882 )
0 commit comments