Example #1
0
def testAlgorithm1SortingWithDifferentPriorities():
    msServicePack = LocalbootProduct.fromHash({
        "priority": 0,
        "packageVersion": "5",
        "productVersion": "xpsp3",
        "id": "msservicepack"
    })

    msHotFix = LocalbootProduct.fromHash({
        "priority": 80,
        "packageVersion": "1",
        "productVersion": "201305",
        "id": "mshotfix"
    })

    productDep = ProductDependency.fromHash({
        "productAction": "setup",
        "requirementType": "after",
        "requiredInstallationStatus": "installed",
        "productVersion": "xpsp3",
        "requiredProductId": "mshotfix",
        "packageVersion": "5",
        "productId": "msservicepack"
    })

    results = SharedAlgorithm.generateProductSequence_algorithm1(
        [msServicePack, msHotFix], [productDep])

    first, second = results
    assert msServicePack.id == first
    assert msHotFix.id == second
Example #2
0
def testAlgorithm1SortingWithAfterSetupDependency():
    renameClient = LocalbootProduct.fromHash({
        "priority": 0,
        "packageVersion": "2",
        "productVersion": "1.0",
        "id": "renameopsiclient",
    })

    winDomain = LocalbootProduct.fromHash({
        "priority": 20,
        "packageVersion": "6",
        "productVersion": "1.0",
        "id": "windomain",
    })

    productDep = ProductDependency.fromHash({
        "productAction": "setup",
        "requirementType": "after",
        "productVersion": "1.0",
        "requiredProductId": "windomain",
        "requiredAction": "setup",
        "packageVersion": "6",
        "productId": "renameopsiclient"
    })

    results = SharedAlgorithm.generateProductSequence_algorithm1(
        [winDomain, renameClient], [productDep])

    first, second = results
    assert renameClient.id == first
    assert winDomain.id == second
Example #3
0
def testCreatingOrderWithImpossibleDependenciesFails(productSequenceAlgorithm):
    products = [{
        "setupScript": "setup.ins",
        "name": "firefox-sequ",
        "priority": 0,
        "packageVersion": "1",
        "productVersion": "1.0",
        "id": "firefox-sequ",
    }, {
        "setupScript": "setup.ins",
        "uninstallScript": "unsetup.ins",
        "name": "flashplayer-sequ",
        "priority": 0,
        "packageVersion": "1",
        "productVersion": "1.0",
        "id": "flashplayer-sequ",
    }, {
        "setupScript": "setup.ins",
        "uninstallScript": "unsetup.ins",
        "name": "javavm-sequ",
        "priority": 0,
        "packageVersion": "1",
        "productVersion": "1.0",
        "id": "javavm-sequ",
    }, {
        "setupScript": "setup.ins",
        "name": "jedit-sequ",
        "priority": 0,
        "packageVersion": "1",
        "productVersion": "1.0",
        "id": "jedit-sequ",
    }, {
        "setupScript": "setup.ins",
        "uninstallScript": "unsetup.ins",
        "name": "sysessential-sequ",
        "priority": 55,
        "packageVersion": "1",
        "productVersion": "1.0",
        "id": "sysessential-sequ",
    }, {
        "setupScript": "setup.ins",
        "uninstallScript": "unsetup.ins",
        "name": "ultravnc-sequ",
        "priority": 0,
        "packageVersion": "1",
        "productVersion": "1.0",
        "id": "ultravnc-sequ",
    }]

    deps = [{
        "productAction": "setup",
        "requirementType": "before",
        "requiredInstallationStatus": "installed",
        "productVersion": "1.0",
        "requiredProductId": "ultravnc-sequ",
        "packageVersion": "1",
        "productId": "firefox-sequ"
    }, {
        "productAction": "setup",
        "requirementType": "before",
        "requiredInstallationStatus": "installed",
        "productVersion": "1.0",
        "requiredProductId": "firefox-sequ",
        "packageVersion": "1",
        "productId": "flashplayer-sequ"
    }, {
        "productAction": "setup",
        "requirementType": "before",
        "requiredInstallationStatus": "installed",
        "productVersion": "1.0",
        "requiredProductId": "firefox-sequ",
        "packageVersion": "1",
        "productId": "javavm-sequ"
    }, {
        "productAction": "setup",
        "requirementType": "before",
        "requiredInstallationStatus": "installed",
        "productVersion": "1.0",
        "requiredProductId": "javavm-sequ",
        "packageVersion": "1",
        "productId": "jedit-sequ"
    }, {
        "productAction": "setup",
        "requirementType": "before",
        "requiredInstallationStatus": "installed",
        "productVersion": "1.0",
        "requiredProductId": "ultravnc-sequ",
        "packageVersion": "1",
        "productId": "sysessential-sequ"
    }, {
        "ident": "ultravnc-sequ;1.0;1;setup;javavm-sequ",
        "productAction": "setup",
        "requirementType": "before",
        "requiredInstallationStatus": "installed",
        "productVersion": "1.0",
        "requiredProductId": "javavm-sequ",
        "packageVersion": "1",
        "productId": "ultravnc-sequ"
    }]

    products = [LocalbootProduct.fromHash(h) for h in products]
    deps = [ProductDependency.fromHash(h) for h in deps]

    with pytest.raises(OpsiProductOrderingError):
        try:
            productSequenceAlgorithm(products, deps)
        except OpsiProductOrderingError as error:
            raise error

    errormessage = forceUnicode(error)

    assert 'firefox-sequ' in errormessage
    assert 'javavm-sequ' in errormessage
    assert 'ultravnc-sequ' in errormessage