def test_create_feature_true():
    strategies = [
        RemoteAddress(parameters={"IPs": IP_LIST}),
        UserWithId(parameters={"userIds": EMAIL_LIST})
    ]
    my_feature = Feature("My Feature", True, strategies)

    CONTEXT["remoteAddress"] = "69.208.0.1"
    assert my_feature.is_enabled(CONTEXT)
    assert my_feature.yes_count == 1

    my_feature.reset_stats()
    assert my_feature.yes_count == 0
def test_create_feature_false():
    strategies = [
        RemoteAddress(parameters={"IPs": IP_LIST}),
        UserWithId(parameters={"userIds": EMAIL_LIST})
    ]
    my_feature = Feature("My Feature", True, strategies)

    CONTEXT["remoteAddress"] = "1.208.0.1"
    CONTEXT["userId"] = "*****@*****.**"
    assert not my_feature.is_enabled(CONTEXT)
    assert my_feature.no_count == 1

    my_feature.reset_stats()
    assert my_feature.no_count == 0
Ejemplo n.º 3
0
def test_create_feature_exception(test_feature):
    strategies = [{}, UserWithId(parameters={"userIds": EMAIL_LIST})]
    my_feature = Feature("My Feature", True, strategies)

    CONTEXT["remoteAddress"] = "69.208.0.1"
    assert not my_feature.is_enabled(CONTEXT)