Skip to content

Conversation

@matthewbalvanz-wf
Copy link
Contributor

  • pact-python now manages the mock service process
  • Moved the project to version v0.2.0

resolves #5 and possibly #7

@mefellows @jslvtr

- Pact now has a `start` method that will start the Ruby mock service
- Pact also has a `stop` method that is expected to be called elsewhere in the user’s test code
- This work is incomplete, the end to end tests don’t produce the desired JSON file as the service is wiping the interactions too soon
- The README.md needs to be updated with new instructions based on these changes
- Change the API so the user can control when the mock service starts and stops
- Update the README.md to illustrate controlling the mock service
- Switch the command line arguments to the mock service to be separate items in a list so
  that they are properly quoted for the shell
- Increment the project to version 0.2.0
@matthewbalvanz-wf matthewbalvanz-wf changed the title Manage mock service pact-python manages the mock service May 2, 2017
@mefellows
Copy link
Member

You're a machine! Great stuff.

@mefellows
Copy link
Member

One thing to consider is when the verification call is made. You may want to consider exposing this to the DSL somehow to the user. In larger Pact tests, if you have several request/response related unit tests but one of them doesn't call the mock service correctly, you won't know if it fails until the process exists (based on what I can glean, this occurs usingatexit and

def __exit__(self, exc_type, exc_val, exc_tb):
).

This could make it hard to see why or where the test failed (i.e. which tests didn't send through the Interaction or sent an unexpected one).

@matthewbalvanz-wf
Copy link
Contributor Author

One thing to consider is when the verification call is made...

Python has a concept called context managers that allow you to run code before and after a block, for example:

pact = Consumer('Consumer').has_pact_with(Provider('Provider'))
with.pact:
    # perform my tests

Before my tests __enter__ is called, after __exit__ is called. __exit__ performs a verification. You do make me think that might not be flexible enough, and that using start/stop as the methods to launch and teardown the Ruby mock service may lead to confusion.

I'll ponder that for a bit and may rearrange some things to make it more clear.

@mefellows
Copy link
Member

Is that at the test class level or individual tests? Another thing to consider is that people may break up tests to a single provider across files as pact tests can be quite lengthy, and that they'll need to use the same running mock server for all of them (this will be made easier when we get the shared lib). That being said, having an opinionated workflow isn't necessarily a bad thing.

- Extracted the logic configuring the mock service and verifying interactions to methods
  for users if they need more control than a context manager provides
@matthewbalvanz-wf
Copy link
Contributor Author

@mefellows I pulled out the setup/verify logic to separate methods so users now have two ways to use the Pact:

  1. As a context manager with the with statement, which calls setup before running the code in the block, and verify after the block completes
  2. Manually calling setup and verify in their code.

I also renamed the start and stop methods to start_service and stop_service to make it more obvious what they were doing.

@mefellows
Copy link
Member

That seems like a great compromise @matthewbalvanz-wf!

@matthewbalvanz-wf matthewbalvanz-wf merged commit 140f583 into master May 13, 2017
@matthewbalvanz-wf matthewbalvanz-wf deleted the manage-mock-service branch May 13, 2017 14:18
matthewbalvanz-wf added a commit that referenced this pull request May 20, 2017
Resolves #12
- Removed the section on running the mock service as that requirement was
  removed in #8
- Expanded the README to include instructions on Ruby configuraiton which
  should have been included in #8
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

Successfully merging this pull request may close these issues.

pact-python starts and stops the mock service

3 participants