Replies: 1 comment
-
@ckp95 yeah, sure, that makes sense. There are two strategies I have used:
def fox():
return [
(GetInput("enter something: "), lambda x: "The Quick Brown Fox"),
(PrintString("the quick brown fox"), noop)
] and then you would set your seq to
1 though I do use something like it when I need effects which "wrap" other effects, like this one which binds some fields into a logging context and then executes another effect: https://github.com/rackerlabs/otter/blob/eb2e0bde6b26badb0d6f5291bc501a641d4b4148/otter/log/intents.py#L62. Then, I test it with the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to get my head around this library and I'm having some trouble understanding how I'm meant to structure Effects that are built out of other Effects, and how to test them. Let's say I have an Intent that represents getting text input from the user:
I write a
@do
-annotated generator function for it:And I test it like this:
So far so good. I also want to have an Effect that represents printing something to the screen, so I write this:
That works fine too.
If I want to combine these two, with some additional processing (converting to lowercase) I know I can do something like this:
But how do I encapsulate these two Effects into one "thing", in a way that can be tested without having to know about the individual sub-Effects that comprise it? In other words, what I would like is to have this:
In such a way that
PrintLowercasedUserInput
somehow encapsulates the action of theprint_lowercased_input
generator.I'm finding it really hard to express what I want with the right vocabulary because this is all quite new to me. Basically when I'm writing tests for a large application I don't want the
seq
in the test to be full of very low level actions, I want to group them together into logical units, each of which has tests itself. Am I making any sense?Beta Was this translation helpful? Give feedback.
All reactions