Beispiel #1
0
def test_create_new_version():
    appliance_path = os.path.join(os.path.dirname(__file__), "appliances",
                                  "microcore-linux.gns3a")

    a = Appliance(registry, appliance_path)

    a.create_new_version("42.0")
    v = a['versions'][-1:][0]
    assert v == {
        'images': {
            'hda_disk_image': {
                'filename': 'linux-microcore-42.0.img',
                'version': '42.0'
            }
        },
        'name': '42.0'
    }

    # tests what happens without versions in file
    wrong_appliance_fp, wrong_appliance_file = tempfile.mkstemp()

    with open(appliance_path) as f:
        appliance = json.loads(f.read())
        del appliance['versions']
        os.write(wrong_appliance_fp, json.dumps(appliance).encode())
        os.close(wrong_appliance_fp)

    a = Appliance(registry, wrong_appliance_file)
    with pytest.raises(ApplianceError):
        a.create_new_version("42.0")

    os.remove(wrong_appliance_file)
Beispiel #2
0
def test_create_new_version():
    appliance_path = os.path.join(
        os.path.dirname(__file__), "appliances", "microcore-linux.gns3a")

    a = Appliance(registry, appliance_path)

    a.create_new_version("42.0")
    v = a['versions'][-1:][0]
    assert v == {
        'images':
        {
            'hda_disk_image':
                {
                    'filename': 'linux-microcore-42.0.img',
                    'version': '42.0'
                }
        },
        'name': '42.0'
    }

    # tests what happens without versions in file
    wrong_appliance_fp, wrong_appliance_file = tempfile.mkstemp()

    with open(appliance_path) as f:
        appliance = json.loads(f.read())
        del appliance['versions']
        os.write(wrong_appliance_fp, json.dumps(appliance).encode())
        os.close(wrong_appliance_fp)

    a = Appliance(registry, wrong_appliance_file)
    with pytest.raises(ApplianceError):
        a.create_new_version("42.0")

    os.remove(wrong_appliance_file)
Beispiel #3
0
def test_create_new_version(microcore_appliance):

    a = Appliance(registry, "tests/registry/appliances/microcore-linux.gns3a")
    a.create_new_version("42.0")
    v = a['versions'][-1:][0]
    assert v == {
        'images': {
            'hda_disk_image': {
                'filename': 'linux-microcore-42.0.img',
                'version': '42.0'
            }
        },
        'name': '42.0'
    }
Beispiel #4
0
def test_create_new_version(microcore_appliance):

    a = Appliance(registry, "tests/registry/appliances/microcore-linux.json")
    a.create_new_version("42.0")
    v = a['versions'][-1:][0]
    assert v == {
        'images':
        {
            'hda_disk_image':
                {
                    'filename': 'linux-microcore-42.0.img',
                    'version': '42.0'
                }
        },
        'name': '42.0'
    }