~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to test_get_ami.py

  • Committer: Curtis Hovey
  • Date: 2015-06-11 19:35:22 UTC
  • mto: This revision was merged to the branch mainline in revision 983.
  • Revision ID: curtis@canonical.com-20150611193522-o2nqkqb04o2i75wv
Remove euca_dump_logs because it has not been used this year.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
            'endpoint~ec2.us-east-1.amazonaws.com',
22
22
            'arch=amd64',
23
23
            'release=precise',
 
24
            'label=release',
24
25
            'root_store=ssd',
25
26
            'virt=pv',
26
27
            '--output-format', '%(id)s'
39
40
            'endpoint~ec2.cn-north-1.amazonaws.com',
40
41
            'arch=amd64',
41
42
            'release=trusty',
42
 
            'root_store=ssd',
43
 
            'virt=pv',
44
 
            '--output-format', '%(id)s'
45
 
        ]
46
 
        with mock.patch("subprocess.check_output", return_value=results,
47
 
                        autospec=True) as co_mock:
48
 
            ami = get_ami.query_ami("trusty", "amd64", region="cn-north-1")
49
 
            self.assertEqual(ami, "ami-first")
50
 
        co_mock.assert_called_once_with(expected_args)
51
 
 
52
 
    def test_query_ami_daily_stream(self):
53
 
        results = "ami-first\nami-second\nami-third\n"
54
 
        expected_args = [
55
 
            'sstream-query',
56
 
            get_ami.DAILY_INDEX,
57
 
            'endpoint~ec2.us-east-1.amazonaws.com',
58
 
            'arch=amd64',
59
 
            'release=trusty',
60
 
            'root_store=ssd',
61
 
            'virt=pv',
62
 
            '--output-format', '%(id)s'
63
 
        ]
64
 
        with mock.patch("subprocess.check_output", return_value=results,
65
 
                        autospec=True) as co_mock:
66
 
            ami = get_ami.query_ami("trusty", "amd64", stream="daily")
 
43
            'label=release',
 
44
            'root_store=ssd',
 
45
            'virt=pv',
 
46
            '--output-format', '%(id)s'
 
47
        ]
 
48
        with mock.patch("subprocess.check_output", return_value=results,
 
49
                        autospec=True) as co_mock:
 
50
            ami = get_ami.query_ami("trusty", "amd64", "cn-north-1")
67
51
            self.assertEqual(ami, "ami-first")
68
52
        co_mock.assert_called_once_with(expected_args)
69
53
 
75
59
            'endpoint~ec2.us-east-1.amazonaws.com',
76
60
            'arch=amd64',
77
61
            'release=trusty',
 
62
            'label=release',
78
63
            'root_store=ebs',
79
64
            'virt=hvm',
80
65
            '--output-format', '%(id)s'
86
71
            self.assertEqual(ami, "ami-first")
87
72
        co_mock.assert_called_once_with(expected_args)
88
73
 
89
 
    def test_query_ami_label(self):
90
 
        results = "ami-first\nami-second\nami-third\n"
91
 
        expected_args = [
92
 
            'sstream-query',
93
 
            get_ami.STREAM_INDEX,
94
 
            'endpoint~ec2.us-east-1.amazonaws.com',
95
 
            'arch=amd64',
96
 
            'release=trusty',
97
 
            'label=release',
98
 
            'root_store=ssd',
99
 
            'virt=pv',
100
 
            '--output-format', '%(id)s'
101
 
        ]
102
 
        with mock.patch("subprocess.check_output", return_value=results,
103
 
                        autospec=True) as co_mock:
104
 
            ami = get_ami.query_ami("trusty", "amd64", label="release")
105
 
            self.assertEqual(ami, "ami-first")
106
 
        co_mock.assert_called_once_with(expected_args)
107
 
 
108
74
    def test_query_ami_missing_tool(self):
109
75
        error = OSError(errno.ENOENT, "not found")
110
76
        message = "sstream-query tool not found, is it installed?"
117
83
 
118
84
    def test_query_no_results(self):
119
85
        message = (
120
 
            "No amis for arch=amd64 release=precise root_store=ssd virt=pv"
121
 
            " in region=us-east-1"
 
86
            "No amis for arch=amd64 release=precise label=release"
 
87
            " root_store=ssd virt=pv in region=us-east-1"
122
88
        )
123
89
        with mock.patch("subprocess.check_output", return_value="",
124
90
                        autospec=True) as co_mock: