コード例 #1
0
def test_num_lesser_op():
    exp = [["inventory.memory.physical_mb", "<", 75537]]
    assert (match_specs(exp, data))
    exp = [["inventory.memory.physical_mb", "!<", 75537]]
    assert (not match_specs(exp, data))
    exp = [["inventory.memory.physical_mb", "<", 55537]]
    assert (not match_specs(exp, data))
コード例 #2
0
def test_str_eq_op():
    exp = [["inventory.boot.current_boot_mode", "eq", "bios"]]
    assert (match_specs(exp, data))
    exp = [["inventory.boot.current_boot_mode", "eq", "test"]]
    assert (not match_specs(exp, data))
    exp = [["inventory.boot.current_boot_mode", "!eq", "test"]]
    assert (match_specs(exp, data))
コード例 #3
0
def test_unknown_op():
    with raises(ValueError):
        exp = [["cpus", "xyz", ["32", "64", "99"]]]
        match_specs(exp, data)
    with raises(ValueError):
        exp = [["cpus", "bleh", ["64", "99"]]]
        match_specs(exp, data)
コード例 #4
0
def test_list_in_op():
    exp = [["cpus", "in", [32, 64, 99]]]
    assert (match_specs(exp, data))
    exp = [["cpus", "in", [64, 99]]]
    assert (not match_specs(exp, data))
    exp = [["cpus", "!in", [64, 99]]]
    assert (match_specs(exp, data))
コード例 #5
0
def test_list_contains_op():
    exp = [["interface", "contains", "eth0"]]
    assert (match_specs(exp, data))
    exp = [["interface", "contains", "xyz"]]
    assert (not match_specs(exp, data))
    exp = [["interface", "!contains", "xyz"]]
    assert (match_specs(exp, data))
コード例 #6
0
def test_str_match_op():
    exp = [["name", "matches", "[a-m]"]]
    assert (match_specs(exp, data))
    exp = [["name", "matches", "[n-z]"]]
    assert (not match_specs(exp, data))
    exp = [["name", "!matches", "[n-z]"]]
    assert (match_specs(exp, data))
コード例 #7
0
def test_num_greater_eq_op():
    exp = [["inventory.memory.physical_mb", ">=", 55536]]
    assert (match_specs(exp, data))
    exp = [["inventory.memory.physical_mb", ">=", 65536]]
    assert (match_specs(exp, data))
    exp = [["inventory.memory.physical_mb", ">=", 75537]]
    assert (not match_specs(exp, data))
    exp = [["inventory.memory.physical_mb", "!>=", 75537]]
    assert (match_specs(exp, data))
コード例 #8
0
def test_str_end_op():
    exp = [["inventory.system_vendor.product_name", "endswith", "M620"]]
    assert (match_specs(exp, data))
    exp = [["inventory.system_vendor.product_name", "endswith", ["M620"]]]
    assert (not match_specs(exp, data))
    exp = [["inventory.system_vendor.product_name", "endswith", "PowerEdge"]]
    assert (not match_specs(exp, data))
    exp = [["inventory.system_vendor.product_name", "!endswith", "PowerEdge"]]
    assert (match_specs(exp, data))
コード例 #9
0
def test_num_not_eq_op():
    exp = [["inventory.memory.physical_mb", "!=", 65536]]
    assert (not match_specs(exp, data))
    exp = [["inventory.memory.physical_mb", "!=", 65537]]
    assert (match_specs(exp, data))
コード例 #10
0
def test_invalid_data_type():
    with raises(ValueError):
        exp = [["inventory.memory.physical_mb", "<=", "755-*37"]]
        match_specs(exp, data)
コード例 #11
0
def test_none_op():
    exp = [["root_disk.rotational", None, "null"]]
    assert (match_specs(exp, data))
    exp = [["root_disk.test_", None, "null"]]
    assert (not match_specs(exp, data))