def testTeardownCluster_WithPrefix(self):
    with mock.patch('gce_api.GceApi') as mock_gce_api_class:
      mock_gce_api_class.return_value.ListInstances.side_effect = [
          [{'name': 'wahoooo'}], []
      ]
      mock_gce_api_class.return_value.ListDisks.side_effect = [
          [{'name': 'wahoooo-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',
          prefix='boo')).TeardownCluster()

      mock_gce_api_class.assert_called_once_with(
          'hadoop_on_compute', mock.ANY, mock.ANY,
          'project-hoge', 'zone-fuga')
      # Make sure prefix is included in instance name patterns.
      (mock_gce_api_class.return_value.ListInstances.
       assert_called_with('name eq "^(boo-hm|boo-hw-\\d+)$"'))
      (mock_gce_api_class.return_value.ListDisks.
       assert_called_with('name eq "^(boo-hm|boo-hw-\\d+)(-data)?$"'))
      self.assertEqual(
          [mock.call('wahoooo')],
          mock_gce_api_class.return_value.DeleteInstance.call_args_list)
      self.assertEqual(
          [mock.call('wahoooo-data')],
          mock_gce_api_class.return_value.DeleteDisk.call_args_list)
Unit test of TeardownCluster() with prefix.
dataset/ETHPy150Open GoogleCloudPlatform/solutions-google-compute-engine-cluster-for-hadoop/gce_cluster_test.py/GceClusterTest.testTeardownCluster_WithPrefix