Merge lp:~frankban/juju-quickstart/new-bundle-lib-no-bundle into lp:juju-quickstart
- new-bundle-lib-no-bundle
- Merge into trunk
Proposed by
Francesco Banconi
Status: | Merged |
---|---|
Merged at revision: | 147 |
Proposed branch: | lp:~frankban/juju-quickstart/new-bundle-lib-no-bundle |
Merge into: | lp:juju-quickstart |
Diff against target: |
199 lines (+31/-18) 7 files modified
quickstart/__init__.py (+1/-1) quickstart/charmstore.py (+1/-1) quickstart/models/bundles.py (+3/-1) quickstart/tests/models/test_bundles.py (+2/-1) quickstart/tests/test_charmstore.py (+19/-9) quickstart/tests/test_manage.py (+1/-1) tox.ini (+4/-4) |
To merge this branch: | bzr merge lp:~frankban/juju-quickstart/new-bundle-lib-no-bundle |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Fabrice Matrat | Approve | ||
Review via email:
|
Commit message
Description of the change
Update to juju-bundlelib 0.4.1.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'quickstart/__init__.py' | |||
2 | --- quickstart/__init__.py 2015-11-23 14:57:26 +0000 | |||
3 | +++ quickstart/__init__.py 2015-12-03 09:56:35 +0000 | |||
4 | @@ -45,7 +45,7 @@ | |||
5 | 45 | Once Juju has been installed, the command can also be run as a juju plugin, | 45 | Once Juju has been installed, the command can also be run as a juju plugin, |
6 | 46 | without the hyphen ("juju quickstart"). | 46 | without the hyphen ("juju quickstart"). |
7 | 47 | """ | 47 | """ |
9 | 48 | VERSION = (2, 2, 3) | 48 | VERSION = (2, 2, 4) |
10 | 49 | 49 | ||
11 | 50 | 50 | ||
12 | 51 | def get_version(): | 51 | def get_version(): |
13 | 52 | 52 | ||
14 | === modified file 'quickstart/charmstore.py' | |||
15 | --- quickstart/charmstore.py 2015-04-21 10:22:46 +0000 | |||
16 | +++ quickstart/charmstore.py 2015-12-03 09:56:35 +0000 | |||
17 | @@ -142,7 +142,7 @@ | |||
18 | 142 | Raise an IOError if any other problems occur while communicating with the | 142 | Raise an IOError if any other problems occur while communicating with the |
19 | 143 | charm store. | 143 | charm store. |
20 | 144 | """ | 144 | """ |
22 | 145 | if not reference.is_bundle(): | 145 | if reference.series and not reference.is_bundle(): |
23 | 146 | raise ValueError( | 146 | raise ValueError( |
24 | 147 | b'expected a bundle, provided charm {}'.format(reference)) | 147 | b'expected a bundle, provided charm {}'.format(reference)) |
25 | 148 | content = get_reference(reference, path) | 148 | content = get_reference(reference, path) |
26 | 149 | 149 | ||
27 | === modified file 'quickstart/models/bundles.py' | |||
28 | --- quickstart/models/bundles.py 2015-11-30 11:18:19 +0000 | |||
29 | +++ quickstart/models/bundles.py 2015-12-03 09:56:35 +0000 | |||
30 | @@ -176,6 +176,8 @@ | |||
31 | 176 | raise | 176 | raise |
32 | 177 | 177 | ||
33 | 178 | # The source refers to a bundle URL in jujucharms.com. | 178 | # The source refers to a bundle URL in jujucharms.com. |
34 | 179 | if not reference.series: | ||
35 | 180 | reference.series = 'bundle' | ||
36 | 179 | try: | 181 | try: |
37 | 180 | data = charmstore.get_bundle_data(reference) | 182 | data = charmstore.get_bundle_data(reference) |
38 | 181 | except charmstore.NotFoundError as err: | 183 | except charmstore.NotFoundError as err: |
39 | @@ -252,7 +254,7 @@ | |||
40 | 252 | reference.charmworld_id = url[len('bundle:'):] | 254 | reference.charmworld_id = url[len('bundle:'):] |
41 | 253 | logging.warn( | 255 | logging.warn( |
42 | 254 | 'this bundle URL is deprecated: please use the new format: ' | 256 | 'this bundle URL is deprecated: please use the new format: ' |
44 | 255 | '{}'.format(reference.jujucharms_id())) | 257 | '{}'.format(reference.copy(series='').jujucharms_id())) |
45 | 256 | return Bundle(data, reference=reference) | 258 | return Bundle(data, reference=reference) |
46 | 257 | 259 | ||
47 | 258 | 260 | ||
48 | 259 | 261 | ||
49 | === modified file 'quickstart/tests/models/test_bundles.py' | |||
50 | --- quickstart/tests/models/test_bundles.py 2015-11-30 11:18:19 +0000 | |||
51 | +++ quickstart/tests/models/test_bundles.py 2015-12-03 09:56:35 +0000 | |||
52 | @@ -344,7 +344,8 @@ | |||
53 | 344 | def test_jujucharms_bundle_invalid_url(self): | 344 | def test_jujucharms_bundle_invalid_url(self): |
54 | 345 | # A ValueError is raised if the provided jujucharms.com identifier is | 345 | # A ValueError is raised if the provided jujucharms.com identifier is |
55 | 346 | # not valid. | 346 | # not valid. |
57 | 347 | with self.assert_value_error('invalid bundle URL: u/no/such/bundle/!'): | 347 | expected_error = 'invalid charm or bundle URL: u/no/such/bundle/!' |
58 | 348 | with self.assert_value_error(expected_error): | ||
59 | 348 | bundles.from_source('u/no/such/bundle/!') | 349 | bundles.from_source('u/no/such/bundle/!') |
60 | 349 | 350 | ||
61 | 350 | def test_jujucharms_bundle_invalid_content(self): | 351 | def test_jujucharms_bundle_invalid_content(self): |
62 | 351 | 352 | ||
63 | === modified file 'quickstart/tests/test_charmstore.py' | |||
64 | --- quickstart/tests/test_charmstore.py 2015-04-21 10:22:46 +0000 | |||
65 | +++ quickstart/tests/test_charmstore.py 2015-12-03 09:56:35 +0000 | |||
66 | @@ -88,7 +88,17 @@ | |||
67 | 88 | content = charmstore.get_reference(ref, '/meta/hash') | 88 | content = charmstore.get_reference(ref, '/meta/hash') |
68 | 89 | self.assertEqual('hash', content) | 89 | self.assertEqual('hash', content) |
69 | 90 | mock_urlread.assert_called_once_with( | 90 | mock_urlread.assert_called_once_with( |
71 | 91 | settings.CHARMSTORE_API + 'bundle/mediawiki-single/meta/hash') | 91 | settings.CHARMSTORE_API + 'mediawiki-single/meta/hash') |
72 | 92 | |||
73 | 93 | def test_success_bundle(self): | ||
74 | 94 | # A GET request to the charm store is correctly performed using the | ||
75 | 95 | # given bundle reference. | ||
76 | 96 | ref = references.Reference.from_jujucharms_url('django/bundle') | ||
77 | 97 | with self.patch_urlread(contents='hash') as mock_urlread: | ||
78 | 98 | content = charmstore.get_reference(ref, '/meta/hash') | ||
79 | 99 | self.assertEqual('hash', content) | ||
80 | 100 | mock_urlread.assert_called_once_with( | ||
81 | 101 | settings.CHARMSTORE_API + 'bundle/django/meta/hash') | ||
82 | 92 | 102 | ||
83 | 93 | def test_success_without_leading_slash(self): | 103 | def test_success_without_leading_slash(self): |
84 | 94 | # The resulting URL is correctly formatted when the static path does | 104 | # The resulting URL is correctly formatted when the static path does |
85 | @@ -120,8 +130,7 @@ | |||
86 | 120 | with self.assertRaises(charmstore.NotFoundError) as ctx: | 130 | with self.assertRaises(charmstore.NotFoundError) as ctx: |
87 | 121 | charmstore.get_reference(ref, '/no/such') | 131 | charmstore.get_reference(ref, '/no/such') |
88 | 122 | expected_error = ( | 132 | expected_error = ( |
91 | 123 | 'charm store resource not found at ' | 133 | 'charm store resource not found at {}django/no/such: ' |
90 | 124 | '{}bundle/django/no/such: ' | ||
92 | 125 | 'bad wolf'.format(settings.CHARMSTORE_API)) | 134 | 'bad wolf'.format(settings.CHARMSTORE_API)) |
93 | 126 | self.assertEqual(expected_error, bytes(ctx.exception)) | 135 | self.assertEqual(expected_error, bytes(ctx.exception)) |
94 | 127 | 136 | ||
95 | @@ -190,7 +199,7 @@ | |||
96 | 190 | 199 | ||
97 | 191 | def test_data_retrieved(self): | 200 | def test_data_retrieved(self): |
98 | 192 | # The bundle data is correctly retrieved and parsed. | 201 | # The bundle data is correctly retrieved and parsed. |
100 | 193 | ref = references.Reference.from_jujucharms_url('django/42') | 202 | ref = references.Reference.from_jujucharms_url('django/bundle/42') |
101 | 194 | with self.patch_urlread(contents=self.bundle_content) as mock_urlread: | 203 | with self.patch_urlread(contents=self.bundle_content) as mock_urlread: |
102 | 195 | data = charmstore.get_bundle_data(ref) | 204 | data = charmstore.get_bundle_data(ref) |
103 | 196 | self.assertEqual(self.bundle_data, data) | 205 | self.assertEqual(self.bundle_data, data) |
104 | @@ -205,7 +214,7 @@ | |||
105 | 205 | charmstore.get_bundle_data(ref) | 214 | charmstore.get_bundle_data(ref) |
106 | 206 | expected_error = ( | 215 | expected_error = ( |
107 | 207 | 'cannot communicate with the charm store at ' | 216 | 'cannot communicate with the charm store at ' |
109 | 208 | '{}bundle/mediawiki-single/archive/bundle.yaml: ' | 217 | '{}mediawiki-single/archive/bundle.yaml: ' |
110 | 209 | 'bad wolf'.format(settings.CHARMSTORE_API)) | 218 | 'bad wolf'.format(settings.CHARMSTORE_API)) |
111 | 210 | self.assertEqual(expected_error, bytes(ctx.exception)) | 219 | self.assertEqual(expected_error, bytes(ctx.exception)) |
112 | 211 | 220 | ||
113 | @@ -217,7 +226,7 @@ | |||
114 | 217 | charmstore.get_bundle_data(ref) | 226 | charmstore.get_bundle_data(ref) |
115 | 218 | expected_error = ( | 227 | expected_error = ( |
116 | 219 | 'charm store resource not found at ' | 228 | 'charm store resource not found at ' |
118 | 220 | '{}bundle/no-such/archive/bundle.yaml: ' | 229 | '{}no-such/archive/bundle.yaml: ' |
119 | 221 | 'bad wolf'.format(settings.CHARMSTORE_API)) | 230 | 'bad wolf'.format(settings.CHARMSTORE_API)) |
120 | 222 | self.assertEqual(expected_error, bytes(ctx.exception)) | 231 | self.assertEqual(expected_error, bytes(ctx.exception)) |
121 | 223 | 232 | ||
122 | @@ -246,7 +255,8 @@ | |||
123 | 246 | 255 | ||
124 | 247 | def test_data_retrieved(self): | 256 | def test_data_retrieved(self): |
125 | 248 | # The legacy bundle data is correctly retrieved and parsed. | 257 | # The legacy bundle data is correctly retrieved and parsed. |
127 | 249 | ref = references.Reference.from_jujucharms_url('u/who/django/42') | 258 | ref = references.Reference.from_jujucharms_url( |
128 | 259 | 'u/who/django/bundle/42') | ||
129 | 250 | contents = self.legacy_bundle_content | 260 | contents = self.legacy_bundle_content |
130 | 251 | with self.patch_urlread(contents=contents) as mock_urlread: | 261 | with self.patch_urlread(contents=contents) as mock_urlread: |
131 | 252 | data = charmstore.get_legacy_bundle_data(ref) | 262 | data = charmstore.get_legacy_bundle_data(ref) |
132 | @@ -263,13 +273,13 @@ | |||
133 | 263 | charmstore.get_legacy_bundle_data(ref) | 273 | charmstore.get_legacy_bundle_data(ref) |
134 | 264 | expected_error = ( | 274 | expected_error = ( |
135 | 265 | 'cannot communicate with the charm store at ' | 275 | 'cannot communicate with the charm store at ' |
137 | 266 | '{}bundle/mediawiki-single/archive/bundles.yaml.orig: ' | 276 | '{}mediawiki-single/archive/bundles.yaml.orig: ' |
138 | 267 | 'bad wolf'.format(settings.CHARMSTORE_API)) | 277 | 'bad wolf'.format(settings.CHARMSTORE_API)) |
139 | 268 | self.assertEqual(expected_error, bytes(ctx.exception)) | 278 | self.assertEqual(expected_error, bytes(ctx.exception)) |
140 | 269 | 279 | ||
141 | 270 | def test_not_found_error(self): | 280 | def test_not_found_error(self): |
142 | 271 | # Not found errors are properly propagated. | 281 | # Not found errors are properly propagated. |
144 | 272 | ref = references.Reference.from_jujucharms_url('no-such') | 282 | ref = references.Reference.from_jujucharms_url('no-such/bundle') |
145 | 273 | with self.patch_urlread(error=netutils.NotFoundError('bad wolf')): | 283 | with self.patch_urlread(error=netutils.NotFoundError('bad wolf')): |
146 | 274 | with self.assertRaises(charmstore.NotFoundError) as ctx: | 284 | with self.assertRaises(charmstore.NotFoundError) as ctx: |
147 | 275 | charmstore.get_legacy_bundle_data(ref) | 285 | charmstore.get_legacy_bundle_data(ref) |
148 | 276 | 286 | ||
149 | === modified file 'quickstart/tests/test_manage.py' | |||
150 | --- quickstart/tests/test_manage.py 2015-10-28 16:45:58 +0000 | |||
151 | +++ quickstart/tests/test_manage.py 2015-12-03 09:56:35 +0000 | |||
152 | @@ -661,7 +661,7 @@ | |||
153 | 661 | with mock.patch('sys.stderr', new_callable=io.StringIO) as mock_stderr: | 661 | with mock.patch('sys.stderr', new_callable=io.StringIO) as mock_stderr: |
154 | 662 | self.call_setup(['invalid/bundle!'], exit_called=False) | 662 | self.call_setup(['invalid/bundle!'], exit_called=False) |
155 | 663 | expected_error = ( | 663 | expected_error = ( |
157 | 664 | 'error: unable to open the bundle: invalid bundle URL: ' | 664 | 'error: unable to open the bundle: invalid charm or bundle URL: ' |
158 | 665 | 'invalid/bundle!') | 665 | 'invalid/bundle!') |
159 | 666 | self.assertIn(expected_error, mock_stderr.getvalue()) | 666 | self.assertIn(expected_error, mock_stderr.getvalue()) |
160 | 667 | 667 | ||
161 | 668 | 668 | ||
162 | === modified file 'tox.ini' | |||
163 | --- tox.ini 2015-11-30 09:18:47 +0000 | |||
164 | +++ tox.ini 2015-12-03 09:56:35 +0000 | |||
165 | @@ -72,7 +72,7 @@ | |||
166 | 72 | # See https://launchpad.net/~juju/+archive/ubuntu/stable. | 72 | # See https://launchpad.net/~juju/+archive/ubuntu/stable. |
167 | 73 | websocket-client==0.18.0 | 73 | websocket-client==0.18.0 |
168 | 74 | jujuclient==0.50.3 | 74 | jujuclient==0.50.3 |
170 | 75 | jujubundlelib==0.3.2 | 75 | jujubundlelib==0.4.1 |
171 | 76 | urwid==1.2.1 | 76 | urwid==1.2.1 |
172 | 77 | # The distribution PyYAML requirement is used in this case. | 77 | # The distribution PyYAML requirement is used in this case. |
173 | 78 | 78 | ||
174 | @@ -82,7 +82,7 @@ | |||
175 | 82 | # Ubuntu 14.04 (trusty) distro dependencies. | 82 | # Ubuntu 14.04 (trusty) distro dependencies. |
176 | 83 | websocket-client==0.12.0 | 83 | websocket-client==0.12.0 |
177 | 84 | jujuclient==0.17.5 | 84 | jujuclient==0.17.5 |
179 | 85 | jujubundlelib==0.3.2 | 85 | jujubundlelib==0.4.1 |
180 | 86 | PyYAML==3.10 | 86 | PyYAML==3.10 |
181 | 87 | urwid==1.1.1 | 87 | urwid==1.1.1 |
182 | 88 | 88 | ||
183 | @@ -92,7 +92,7 @@ | |||
184 | 92 | # Ubuntu 15.04 (vivid) distro dependencies. | 92 | # Ubuntu 15.04 (vivid) distro dependencies. |
185 | 93 | websocket-client==0.18.0 | 93 | websocket-client==0.18.0 |
186 | 94 | jujuclient==0.18.5 | 94 | jujuclient==0.18.5 |
188 | 95 | jujubundlelib==0.3.2 | 95 | jujubundlelib==0.4.1 |
189 | 96 | PyYAML==3.11 | 96 | PyYAML==3.11 |
190 | 97 | urwid==1.2.1 | 97 | urwid==1.2.1 |
191 | 98 | 98 | ||
192 | @@ -102,7 +102,7 @@ | |||
193 | 102 | # Ubuntu 15.10 (wily) distro dependencies. | 102 | # Ubuntu 15.10 (wily) distro dependencies. |
194 | 103 | websocket-client==0.18.0 | 103 | websocket-client==0.18.0 |
195 | 104 | jujuclient==0.50.1 | 104 | jujuclient==0.50.1 |
197 | 105 | jujubundlelib==0.3.2 | 105 | jujubundlelib==0.4.1 |
198 | 106 | PyYAML==3.11 | 106 | PyYAML==3.11 |
199 | 107 | urwid==1.2.1 | 107 | urwid==1.2.1 |
200 | 108 | 108 |
LGTM