def testTeardownCluster(self):
    with mock.patch('gce_api.GceApi') as mock_gce_api_class:
      mock_gce_api_class.return_value.ListInstances.side_effect = [
          [
              {'name': 'fugafuga'},
              {'name': 'hogehoge'},
              {'name': 'piyopiyo'},
          ], []
      ]
      mock_gce_api_class.return_value.ListDisks.side_effect = [
          [
              {'name': 'fugafuga-data'},
              {'name': 'hogehoge-data'},
              {'name': 'piyopiyo-data'},
          ], []
      ]
      mock_gce_api_class.return_value.GetInstance.return_value = None
      mock_gce_api_class.return_value.GetDisk.return_value = None

      GceCluster(argparse.Namespace(
          project='project-hoge', zone='zone-fuga')).TeardownCluster()

      mock_gce_api_class.assert_called_once_with(
          'hadoop_on_compute', mock.ANY, mock.ANY,
          'project-hoge', 'zone-fuga')
      (mock_gce_api_class.return_value.ListInstances.
       assert_called_with('name eq "^(hm|hw-\\d+)$"'))
      (mock_gce_api_class.return_value.ListDisks.
       assert_called_with('name eq "^(hm|hw-\\d+)(-data)?$"'))
      # Make sure DeleteInstance() is called for each instance.
      self.assertEqual(
          [mock.call('fugafuga'), mock.call('hogehoge'),
           mock.call('piyopiyo')],
          mock_gce_api_class.return_value.DeleteInstance.call_args_list)
      self.assertEqual(
          [mock.call('fugafuga-data'), mock.call('hogehoge-data'),
           mock.call('piyopiyo-data')],
          mock_gce_api_class.return_value.DeleteDisk.call_args_list)
Simulate portfolio execution on a train/test split.
dataset/ETHPy150Open GoogleCloudPlatform/solutions-google-compute-engine-cluster-for-hadoop/gce_cluster_test.py/GceClusterTest.testTeardownCluster--crossover with--dataset/ETHPy150Open borg-project/borg/borg/tools/simulate.py/simulate_split