|
| 1 | +from radish.stepregistry import given, step, then, when |
| 2 | +from radish.terrain import pick, world |
| 3 | + |
| 4 | + |
| 5 | +@step("I don't have a pick decorated method") |
| 6 | +def dont_have_pick_method(step): |
| 7 | + if hasattr(world, "pick_decorated"): |
| 8 | + delattr(world, "pick_decorated") |
| 9 | + |
| 10 | + |
| 11 | +@given("I have a method decorated with pick") |
| 12 | +def add_pick_step(step): |
| 13 | + @pick |
| 14 | + def pick_decorated(): |
| 15 | + return 42 |
| 16 | + |
| 17 | + step.context.decorate_method_name = pick_decorated.__name__ |
| 18 | + |
| 19 | + |
| 20 | +@then("I expect the pick step to be in the world") |
| 21 | +def expect_pick_step(step): |
| 22 | + assert hasattr(world, "pick_decorated"), "World is missing the decorated method pick_decorated" |
| 23 | + |
| 24 | + |
| 25 | +@then("I expect the pick step not to be in the world") |
| 26 | +def expect_pick_step_missing(step): |
| 27 | + assert not hasattr(world, "pick_decorated"), "World has the decorated method pick_decorated" |
| 28 | + |
| 29 | + |
| 30 | +@when("I call the pick decorated method") |
| 31 | +def call_pick_decorated_method(step): |
| 32 | + step.context.pick_result = world.pick_decorated() |
| 33 | + |
| 34 | + |
| 35 | +@then("I expect the pick result to be {expected_result:d}") |
| 36 | +def expect_pick_result(step, expected_result): |
| 37 | + assert step.context.pick_result == expected_result, ( |
| 38 | + f"Expected pick result to be {expected_result} but was {step.context.pick_result}" |
| 39 | + ) |
0 commit comments