1+ import sys
2+
3+ if sys .version_info [0 ] >= 3 :
4+ from unittest import mock
5+ else :
6+ import mock
7+
8+ import six
9+
10+ from openml .testing import TestBase
11+ import openml
12+
13+
14+ class TestInit (TestBase ):
15+
16+ @mock .patch ('openml.tasks.functions.get_task' )
17+ @mock .patch ('openml.datasets.functions.get_dataset' )
18+ @mock .patch ('openml.flows.functions.get_flow' )
19+ @mock .patch ('openml.runs.functions.get_run' )
20+ def test_populate_cache (self , run_mock , flow_mock , dataset_mock , task_mock ):
21+ openml .populate_cache (task_ids = [1 , 2 ], dataset_ids = [3 , 4 ],
22+ flow_ids = [5 , 6 ], run_ids = [7 , 8 ])
23+ self .assertEqual (run_mock .call_count , 2 )
24+ for argument , fixture in six .moves .zip (run_mock .call_args_list , [(7 ,), (8 ,)]):
25+ self .assertEqual (argument [0 ], fixture )
26+
27+ self .assertEqual (flow_mock .call_count , 2 )
28+ for argument , fixture in six .moves .zip (flow_mock .call_args_list , [(5 ,), (6 ,)]):
29+ self .assertEqual (argument [0 ], fixture )
30+
31+ self .assertEqual (dataset_mock .call_count , 2 )
32+ for argument , fixture in six .moves .zip (dataset_mock .call_args_list , [(3 ,), (4 ,)]):
33+ self .assertEqual (argument [0 ], fixture )
34+
35+ self .assertEqual (task_mock .call_count , 2 )
36+ for argument , fixture in six .moves .zip (task_mock .call_args_list , [(1 ,), (2 ,)]):
37+ self .assertEqual (argument [0 ], fixture )
38+
0 commit comments