Merge lp://staging/~fwereade/pyjuju/fix-mocking into lp://staging/pyjuju

Proposed by William Reade
Status: Merged
Approved by: Gustavo Niemeyer
Approved revision: 281
Merged at revision: 285
Proposed branch: lp://staging/~fwereade/pyjuju/fix-mocking
Merge into: lp://staging/pyjuju
Diff against target: 173 lines (+64/-16)
4 files modified
ensemble/providers/ec2/tests/common.py (+12/-7)
ensemble/providers/ec2/tests/test_bootstrap.py (+4/-4)
ensemble/providers/ec2/tests/test_launch.py (+48/-4)
ensemble/providers/ec2/utils.py (+0/-1)
To merge this branch: bzr merge lp://staging/~fwereade/pyjuju/fix-mocking
Reviewer Review Type Date Requested Status
Gustavo Niemeyer Approve
Kapil Thangavelu (community) Approve
Jim Baker Pending
Review via email: mp+68925@code.staging.launchpad.net

Description of the change

Tests now run with no network.

Not sure how to reliably induce a flaky network to see whether it affects possibly-related timeouts.

Coverage of the code we were failing to mock correctly is now improved.

To post a comment you must log in.
Revision history for this message
Kapil Thangavelu (hazmat) wrote :

looks good, and works nicely disconnected.

review: Approve
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Looks good. Just a minor suggestion:

[1]

24 + if not get_ami_kwargs:
25 + return
26 + get_ami = self.mocker.replace(
27 + "ensemble.providers.ec2.utils.get_current_ami")
28 + get_ami(**get_ami_kwargs)
29 + self.mocker.result(succeed("ami-714ba518"))

I suggest using something like this (untested):

get_ami(KWARGS)
def check_kwargs(**kwargs):
    self.assertEquals(kwargs, get_ami_kwargs)
    return succeed("ami-...")
self.mocker.call(check_kwargs)

The distinction between the two approaches is that with the original version it will
ignore all requests that do not match the provided kwargs, and pass them through.
This version will capture all calls, and ensure they match the expectation.

review: Approve
282. By William Reade

merge from trunk

283. By William Reade

improved test per niemeyer's suggestion

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: