Beispiel #1
0
def test_ec2_to_json():
    test_instance = ec2_instance_mock()
    test_instance.state_reason = None
    test_instance.image = None
    result = ec2_to_json(test_instance)
    assert result['state'] == test_instance.state['Name']
    assert result['image_id'] == test_instance.image_id
    assert result['instance_lifecycle'] == test_instance.instance_lifecycle
    assert result['instance_type'] == test_instance.instance_type
    assert result['kernel_id'] == test_instance.kernel_id
    assert result['launch_time'] == test_instance.launch_time.isoformat()
    assert result['public_ip_address'] == test_instance.public_ip_address
    assert len(result['security_groups']) == len(test_instance.security_groups)
    # TODO compare values of 'security_groups'
    assert result['sriov_net_support'] == test_instance.sriov_net_support
    for t in test_instance.tags:
        assert result['tags'][t['Key']] == t['Value']
    assert 'state_reason' not in result
    assert 'image' not in result
Beispiel #2
0
def test_ec2_to_json_image_with_meta():
    test_instance = ec2_instance_mock()
    result = ec2_to_json(test_instance)
    assert result['image']['name'] == test_instance.image.name
Beispiel #3
0
def test_ec2_to_json_image_without_meta():
    test_instance = ec2_instance_mock()
    test_instance.image.meta.data = None
    result = ec2_to_json(test_instance)
    assert result['image']['image_id'] == test_instance.image.image_id
    assert 'name' not in result['image']
Beispiel #4
0
def test_ec2_to_json_state_reason():
    test_instance = ec2_instance_mock()
    result = ec2_to_json(test_instance)
    assert result['state_reason'] == test_instance.state_reason['Message']