コード例 #1
0
def test_gce_to_json_metadata_items():
    test_instance = gce_instance_mock()
    test_items = [{'key': fake.uuid4(), 'value': fake.uuid4()}, {'key': fake.uuid4(), 'value': fake.uuid4()}]
    test_instance['metadata'] = {'items': test_items}
    result = gce_to_json(test_instance)

    assert len(result['tags']) == 2
コード例 #2
0
def test_gce_to_json_launch_time():
    test_instance = gce_instance_mock()
    test_time = datetime.now()
    test_items = [{'key': 'openqa_created_date', 'value': test_time}]
    test_instance['metadata'] = {'items': test_items}
    result = gce_to_json(test_instance)

    assert result['launch_time'] == test_time
コード例 #3
0
def test_gce_to_json():
    test_instance = gce_instance_mock()
    result = gce_to_json(test_instance)

    assert result['name'] == test_instance['name']
    assert result['id'] == test_instance['id']
    assert result['machineType'] == GCE.url_to_name(test_instance['machineType'])
    assert result['zone'] == GCE.url_to_name(test_instance['zone'])
    assert result['status'] == test_instance['status']
    assert result['launch_time'] == test_instance['creationTimestamp']
    assert result['creation_time'] == test_instance['creationTimestamp']
    assert len(result['tags']) == 0
    assert 'sshKeys' not in result['tags']