def testListInstance_Filter(self):
    mock_api = MagicMock(name='Mock Google Client API')
    self.gce_api.GetApi = MagicMock(return_value=mock_api)
    mock_api.instances.return_value.list.return_value.execute.return_value = {
        'items': ['dummy', 'list']
    }

    instance_list = self.gce_api.ListInstances('filter condition')

    self.assertEqual(1, self.gce_api.GetApi.call_count)
    mock_api.instances.return_value.list.assert_called_once_with(
        project='project-name', zone='zone-name', filter='filter condition')
    (mock_api.instances.return_value.list.return_value.execute.
     assert_called_once_with())
    self.assertEqual(['dummy', 'list'], instance_list)
Unit test of ListInstance() with filter string.
dataset/ETHPy150Open GoogleCloudPlatform/Solutions-Using-ETL-tool-on-Google-Compute-Engine/gce_api_test.py/GceApiTest.testListInstance_Filter