예제 #1
0
def test_describe_terminated(mock_aws_config):
    launch(mock_aws_config, "alice", ami_id)
    launch(mock_aws_config, "sam", ami_id)
    terminate(mock_aws_config, "sam")

    # by default don't show terminated instances
    instances = describe(config=mock_aws_config)
    assert len(instances) == 1
    assert instances[0]["Name"] == "alice"

    # when requested, show terminated instances
    instances = describe(config=mock_aws_config, include_terminated=True)
    assert len(instances) == 2
예제 #2
0
def test_describe_instance_id(mock_aws_config):
    instances = launch(mock_aws_config, "alice", ami_id)
    instance_id = instances[0]["InstanceId"]

    instances = describe(config=mock_aws_config, name=instance_id)
    assert len(instances) == 1
    assert instances[0]["Name"] == "alice"
예제 #3
0
def test_describe_by_name_match(mock_aws_config):
    launch(mock_aws_config, "alice", ami_id)
    launch(mock_aws_config, "alex", ami_id)

    instances = describe(config=mock_aws_config, name_match="lic")

    assert len(instances) == 1
    assert instances[0]["Name"] == "alice"
예제 #4
0
def test_describe_running_only(mock_aws_config):
    launch(mock_aws_config, "alice", ami_id)
    launch(mock_aws_config, "sam", ami_id)
    stop(mock_aws_config, "sam")

    # show only running instances
    instances = describe(config=mock_aws_config, show_running_only=True)
    assert len(instances) == 1
    assert instances[0]["Name"] == "alice"
예제 #5
0
def test_describe_instance_without_tags(mock_aws_config):
    # create instance without tags
    ec2_client = boto3.client("ec2", region_name=mock_aws_config["region"])
    ec2_client.run_instances(MaxCount=1, MinCount=1)

    instances = describe(config=mock_aws_config)
    print(instances)

    assert len(instances) == 1
예제 #6
0
def test_describe(mock_aws_config):
    launch(mock_aws_config, "alice", ami_id)
    launch(mock_aws_config, "sam", ami_id)

    instances = describe(config=mock_aws_config)
    print(instances)

    assert len(instances) == 2
    assert instances[0]["Name"] == "alice"
    assert instances[1]["Name"] == "sam"
예제 #7
0
def test_describe_columns(mock_aws_config):
    launch(mock_aws_config, "sam", ami_id)
    launch(mock_aws_config, "alice", ami_id)

    instances = describe(config=mock_aws_config, columns="SubnetId,Name")
    print(instances)

    assert len(instances) == 2
    assert instances[0]["Name"] == "alice"
    assert instances[1]["Name"] == "sam"
    assert "subnet" in instances[0]["SubnetId"]
    assert "subnet" in instances[1]["SubnetId"]