1# Copyright 2015, Google, Inc. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import os 15import uuid 16 17import pytest 18 19from create_instance import main 20 21PROJECT = os.environ['GOOGLE_CLOUD_PROJECT'] 22BUCKET = os.environ['CLOUD_STORAGE_BUCKET'] 23 24 25@pytest.mark.flaky(max_runs=3, min_passes=1) 26def test_main(capsys): 27 instance_name = 'test-instance-{}'.format(uuid.uuid4()) 28 main( 29 PROJECT, 30 BUCKET, 31 'us-central1-f', 32 instance_name, 33 wait=False) 34 35 out, _ = capsys.readouterr() 36 37 assert "Instances in project" in out 38 assert "zone us-central1-f" in out 39 assert instance_name in out 40 assert "Deleting instance" in out 41