예제 #1
0
def test_stepregistry_is_initialized_with_no_step_impls():
    """The StepRegistry should be initialized with no registered Step Implementations"""
    # given & when
    registry = StepRegistry()

    # then
    assert registry.step_implementations() == {}
예제 #2
0
def test_stepregistry_should_allow_to_register_step_impls():
    """The StepRegistry should allow to register a Step Implementation"""
    # given
    registry = StepRegistry()

    # when
    registry.register("Given", "pattern", None)

    # then
    assert registry.step_implementations("Given") == [
        StepImpl("Given", "pattern", None)
    ]
예제 #3
0
def test_stepregitry_register_func_with_multiple_decorators():
    """The StepRegistry should allow a function to be registered with multiple Step decorators"""
    # given
    registry = StepRegistry()
    context = {}
    registry.create_step_decorators(context)

    # when
    def test_step():
        ...

    test_step = context["given"]("pattern")(test_step)
    test_step = context["when"]("pattern")(test_step)

    # then
    assert registry.step_implementations("Given") == [
        StepImpl("Given", "pattern", test_step)
    ]
    assert registry.step_implementations("When") == [
        StepImpl("When", "pattern", test_step)
    ]
예제 #4
0
def test_stepregistry_should_gracefully_accept_double_registration():
    """
    The StepRegistry should gracefully accept a duplicate registration of a Step Implementation
    """
    # given
    registry = StepRegistry()
    registry.register("Given", "pattern", None)

    # when
    registry.register("Given", "pattern", None)

    # then
    assert registry.step_implementations("Given") == [
        StepImpl("Given", "pattern", None)
    ]
예제 #5
0
def test_stepregistry_step_decorator_should_register_func_with_proper_keyword(keyword):
    """The StepRegistry should create one Step decorator for each keyword"""
    # given
    registry = StepRegistry()
    context = {}
    registry.create_step_decorators(context)

    # when
    def test_step():
        ...

    test_step = context[keyword.lower()]("pattern")(test_step)

    # then
    assert registry.step_implementations(keyword) == [
        StepImpl(keyword, "pattern", test_step)
    ]
예제 #6
0
def test_stepregitry_step_decorators_for_all_keywords():
    """The StepRegistry should return the Step Implementations registered
    with the ``step`` decorator for all keywords.
    """
    # given
    registry = StepRegistry()
    context = {}
    registry.create_step_decorators(context)

    # when
    def test_step():
        ...

    test_step = context["step"]("pattern")(test_step)

    # then
    assert registry.step_implementations("Given") == [
        StepImpl("Step", "pattern", test_step)
    ]