~juju/ubuntu/quantal/juju/0.6

« back to all changes in this revision

Viewing changes to juju/providers/ec2/tests/common.py

  • Committer: Clint Byrum
  • Date: 2012-04-10 00:16:52 UTC
  • mfrom: (1.1.11)
  • Revision ID: clint@ubuntu.com-20120410001652-1uskc8x0fwpo0r2n
* New upstream snapshot
* d/p/fix-tests-without-aws-key.patch: Dropped as it has been
  superseded by a better upstream fix (LP: #819329)
* d/p/no-write-sample-on-help.patch: Dropped, Applied upstream.
* d/p/disable-failing-zookeeper-test.patch refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from yaml import dump
2
2
 
3
 
from twisted.internet.defer import fail, succeed
 
3
from twisted.internet.defer import fail, succeed, inlineCallbacks, returnValue
4
4
 
5
5
from txaws.s3.client import S3Client
6
6
from txaws.s3.exception import S3Error
14
14
 
15
15
MATCH_GROUP = MATCH(lambda x: x.startswith("juju-moon"))
16
16
 
 
17
_constraints_provider = MachineProvider(
 
18
    "", {"access-key": "fog", "secret-key": "snow"})
 
19
 
 
20
 
 
21
@inlineCallbacks
 
22
def get_constraints(strs, series="splendid"):
 
23
    cs = yield _constraints_provider.get_constraint_set()
 
24
    returnValue(cs.parse(strs).with_series(series))
 
25
 
17
26
 
18
27
class EC2TestMixin(object):
19
28
 
26
35
                "admin-secret": "magic-beans",
27
36
                "access-key": "0f62e973d5f8",
28
37
                "secret-key": "3e5a7c653f59",
29
 
                "control-bucket": self.env_name}
 
38
                "control-bucket": self.env_name,
 
39
                "default-series": "splendid"}
30
40
 
31
41
    def get_provider(self):
32
42
        """Return the ec2 machine provider.
81
91
 
82
92
class EC2MachineLaunchMixin(object):
83
93
 
84
 
    def _mock_launch_utils(self, ami_name="ami-default", **get_ami_kwargs):
 
94
    def _mock_launch_utils(self, ami_name="ami-default", get_ami_args=()):
85
95
        get_public_key = self.mocker.replace(
86
96
            "juju.providers.common.utils.get_user_authorized_keys")
87
97
 
91
101
        get_public_key(MATCH(match_config))
92
102
        self.mocker.result("zebra")
93
103
 
94
 
        if not get_ami_kwargs:
95
 
            return
 
104
        get_ami_args = get_ami_args or (
 
105
            "splendid", "amd64", "us-east-1", False)
96
106
        get_ami = self.mocker.replace(
97
107
            "juju.providers.ec2.utils.get_current_ami")
98
 
        get_ami(KWARGS)
99
 
 
100
 
        def check_kwargs(**kwargs):
101
 
            self.assertEquals(kwargs, get_ami_kwargs)
102
 
            return succeed(ami_name)
103
 
        self.mocker.call(check_kwargs)
 
108
        get_ami(*get_ami_args)
 
109
        self.mocker.result(succeed(ami_name))
104
110
 
105
111
    def _mock_create_group(self):
106
112
        group_name = "juju-%s" % self.env_name