Пример #1
0
def test_wcp_implies_caseinsensitive_returns_false(
        wildcardstring1, wildcardstring2):
    """
    unit tested:  implies

    test case:
    Case insensitive, single-name permission, returns False
    """
    p1 = WildcardPermission(wildcardstring1)
    p2 = WildcardPermission(wildcardstring2)
    assert not p1.implies(p2)
Пример #2
0
def test_wcp_implies_caseinsensitive_returns_true(
        wildcardstring1, wildcardstring2):
    """
    unit tested:  implies

    test case:
    Case insensitive, single-name permission, returns True
    """
    p1 = WildcardPermission(wildcardstring1)
    p2 = WildcardPermission(wildcardstring2)
    assert p1.implies(p2)
Пример #3
0
def test_wcp_implies_caseinsensitive_wildcards_false(
        wildcardstring1, wildcardstring2):
    """
    unit tested:  implies

    test case:
    Case insensitive, wildcard-based permission, retrns False
    """
    p1 = WildcardPermission(wildcard_string=wildcardstring1)
    p2 = WildcardPermission(wildcard_string=wildcardstring2)

    assert not p1.implies(p2)
Пример #4
0
def test_wcp_implies_caseinsensitive_wildcards_false(
        wildcardstring1, wildcardstring2):
    """
    unit tested:  implies

    test case:
    Case insensitive, wildcard-based permission, retrns False
    """
    p1 = WildcardPermission(wildcard_string=wildcardstring1)
    p2 = WildcardPermission(wildcard_string=wildcardstring2)

    assert not p1.implies(p2)
Пример #5
0
def test_wcp_equals():
    """
    unit tested:

    test case:

    """

    wildcard_string = 'somestring'
    p1 = WildcardPermission(wildcard_string)
    p2 = WildcardPermission(wildcard_string)

    assert p1 == p2
Пример #6
0
def test_wcp_implies_casesensitive_returns_false(
        wildcardstring1, wildcardstring2):
    """
    unit tested:  implies

    test case:
    Case sensitive, single-name permission, returns False
    """
    p1 = WildcardPermission(wildcard_string=wildcardstring1,
                            case_sensitive=True)
    p2 = WildcardPermission(wildcard_string=wildcardstring2,
                            case_sensitive=True)
    assert not p1.implies(p2)
Пример #7
0
def test_wcp_implies_caseinsensitive_lists(
        wildcardstring1, wildcardstring2):
    """
    unit tested:  implies

    test case:
    Case insensitive, list-based permission, retrns True and the opposite False
    """

    p1 = WildcardPermission(wildcard_string=wildcardstring1)
    p2 = WildcardPermission(wildcard_string=wildcardstring2)

    assert p1.implies(p2) and not p2.implies(p1)
Пример #8
0
def test_wcp_implies_casesensitive_returns_true(
        wildcardstring1, wildcardstring2):
    """
    unit tested:  implies

    test case:
    Case sensitive, single-name permission,returns True
    """
    p1 = WildcardPermission(wildcard_string=wildcardstring1,
                            case_sensitive=True)
    p2 = WildcardPermission(wildcard_string=wildcardstring2,
                            case_sensitive=True)
    assert p1.implies(p2)
Пример #9
0
def test_wcp_init_without_wildcard_string(monkeypatch):
    """
    unit tested:  __init__

    test case:
    control flow depending on whether a wildcard_string is passed
    """
    with mock.patch.object(WildcardPermission, 'setparts') as wp_sp:
        wp_sp.return_value = None
        with pytest.raises(ValueError):
            wcs = WildcardPermission()
Пример #10
0
def test_wcp_init_with_wildcard_string(monkeypatch):
    """
    unit tested:  __init__

    test case:
    control flow depending on whether a wildcard_string is passed
    """
    with mock.patch.object(WildcardPermission, 'setparts') as wp_sp:
        wp_sp.return_value = None
        wcs = WildcardPermission(wildcard_string='DOMAIN:ACTION:INSTANCE')
        assert wcs.setparts.called
Пример #11
0
def test_wcp_not_equals_bad_type():
    """
    unit tested:

    test case:

    """
    wildcard_string = 'somestring'
    p1 = WildcardPermission(wildcard_string)
    othertype = type('OtherPermissionType', (object,), {})
    p2 = othertype()

    assert not p1 == p2
Пример #12
0
def test_wcp_implies_caseinsensitive_lists(wildcardstring1, wildcardstring2):
    """
    unit tested:  implies

    test case:
    Case insensitive, list-based permission, retrns True and the opposite False
    """

    p1 = WildcardPermission(wildcard_string=wildcardstring1)
    p2 = WildcardPermission(wildcard_string=wildcardstring2)

    assert p1.implies(p2) and not p2.implies(p1)
Пример #13
0
def default_wildcard_permission():
    return WildcardPermission()