Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify expect_oneshot_request and expect_request #9

Closed
rominf opened this issue Mar 4, 2019 · 2 comments
Closed

Unify expect_oneshot_request and expect_request #9

rominf opened this issue Mar 4, 2019 · 2 comments

Comments

@rominf
Copy link
Contributor

rominf commented Mar 4, 2019

expect_oneshot_request and expect_request are responsible for similar actions, but expect_oneshot_request takes one optional keyword argument more (ordered). I propose to:

  1. Define enum HandlerType:
class HandlerType(Enum):
    PERMANENT = 'permanent'
    ONESHOT = 'oneshot'
    ORDERED = 'ordered'
  1. Make expect_request universal so that it could register permanent, oneshot, and ordered handlers by adding optional enum HandlerType argument.
  2. Remove ordered argument from expect_oneshot_request.
  3. Add convinience method expect_ordered_request.
@csernazs
Copy link
Owner

csernazs commented Mar 6, 2019

That's a good idea.
And the code would also be better because self.create_matcher would be called at only one place, in the expect_request method.

@csernazs
Copy link
Owner

csernazs commented Mar 6, 2019

The optional keyword argument could be type or something like that, as ordered=HandlerType.ONESHOT does not look good, as having a oneshot rule is orthogonal to whether it is ordered or not.
But this is just about the naming. :)

csernazs pushed a commit that referenced this issue Mar 9, 2019
This change is not backward compatible!

1. Define enum `HandlerType`.
2. Make `expect_request` universal so that it could register permanent,
oneshot, and ordered handlers by adding enum `HandlerType` argument with
default value `HandlerType.PERMANENT`.
3. Remove ordered argument from expect_oneshot_request.
4. Add convenience method expect_ordered_request.

Fixes #9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants