|
14 | 14 | from stacker import exceptions |
15 | 15 | from stacker.lookups.registry import LOOKUP_HANDLERS |
16 | 16 |
|
| 17 | +from yaml.constructor import ConstructorError |
| 18 | + |
17 | 19 | config = """a: $a |
18 | 20 | b: $b |
19 | 21 | c: $c""" |
@@ -97,7 +99,7 @@ def test_config_validate_duplicate_stack_names(self): |
97 | 99 | error = ex.exception.errors['stacks'][0] |
98 | 100 | self.assertEquals( |
99 | 101 | error.__str__(), |
100 | | - "Duplicate stack bastion found at index 1.") |
| 102 | + "Duplicate stack bastion found at index 0.") |
101 | 103 |
|
102 | 104 | def test_dump_unicode(self): |
103 | 105 | config = Config() |
@@ -196,6 +198,15 @@ def test_parse(self): |
196 | 198 | args: |
197 | 199 | domain: mydomain.com |
198 | 200 | package_sources: |
| 201 | + s3: |
| 202 | + - bucket: acmecorpbucket |
| 203 | + key: public/acmecorp-blueprints-v1.zip |
| 204 | + - bucket: examplecorpbucket |
| 205 | + key: public/examplecorp-blueprints-v2.tar.gz |
| 206 | + requester_pays: true |
| 207 | + - bucket: anotherexamplebucket |
| 208 | + key: example-blueprints-v3.tar.gz |
| 209 | + use_latest: false |
199 | 210 | git: |
200 | 211 | - uri: git@github.com:acmecorp/stacker_blueprints.git |
201 | 212 | - uri: git@github.com:remind101/stacker_blueprints.git |
@@ -248,6 +259,15 @@ def test_parse(self): |
248 | 259 | args: |
249 | 260 | domain: mydomain.com |
250 | 261 | package_sources: |
| 262 | + s3: |
| 263 | + - bucket: acmecorpbucket |
| 264 | + key: public/acmecorp-blueprints-v1.zip |
| 265 | + - bucket: examplecorpbucket |
| 266 | + key: public/examplecorp-blueprints-v2.tar.gz |
| 267 | + requester_pays: true |
| 268 | + - bucket: anotherexamplebucket |
| 269 | + key: example-blueprints-v3.tar.gz |
| 270 | + use_latest: false |
251 | 271 | git: |
252 | 272 | - uri: git@github.com:acmecorp/stacker_blueprints.git |
253 | 273 | - uri: git@github.com:remind101/stacker_blueprints.git |
@@ -290,6 +310,25 @@ def test_parse(self): |
290 | 310 | self.assertEqual( |
291 | 311 | hooks[0].args, {"domain": "mydomain.com"}) |
292 | 312 |
|
| 313 | + self.assertEqual( |
| 314 | + config.package_sources.s3[0].bucket, |
| 315 | + "acmecorpbucket") |
| 316 | + self.assertEqual( |
| 317 | + config.package_sources.s3[0].key, |
| 318 | + "public/acmecorp-blueprints-v1.zip") |
| 319 | + self.assertEqual( |
| 320 | + config.package_sources.s3[1].bucket, |
| 321 | + "examplecorpbucket") |
| 322 | + self.assertEqual( |
| 323 | + config.package_sources.s3[1].key, |
| 324 | + "public/examplecorp-blueprints-v2.tar.gz") |
| 325 | + self.assertEqual( |
| 326 | + config.package_sources.s3[1].requester_pays, |
| 327 | + True) |
| 328 | + self.assertEqual( |
| 329 | + config.package_sources.s3[2].use_latest, |
| 330 | + False) |
| 331 | + |
293 | 332 | self.assertEqual( |
294 | 333 | config.package_sources.git[0].uri, |
295 | 334 | "git@github.com:acmecorp/stacker_blueprints.git") |
@@ -398,6 +437,29 @@ def test_render_parse_load_namespace_fallback(self): |
398 | 437 | config.validate() |
399 | 438 | self.assertEquals(config.namespace, "prod") |
400 | 439 |
|
| 440 | + def test_raise_constructor_error_on_duplicate_key(self): |
| 441 | + yaml_config = """ |
| 442 | + namespace: prod |
| 443 | + stacks: |
| 444 | + - name: vpc |
| 445 | + class_path: blueprints.VPC |
| 446 | + class_path: blueprints.Fake |
| 447 | + """ |
| 448 | + with self.assertRaises(ConstructorError): |
| 449 | + parse(yaml_config) |
| 450 | + |
| 451 | + def test_raise_construct_error_on_duplicate_stack_name(self): |
| 452 | + yaml_config = """ |
| 453 | + namespace: prod |
| 454 | + stacks: |
| 455 | + my_vpc: |
| 456 | + class_path: blueprints.VPC1 |
| 457 | + my_vpc: |
| 458 | + class_path: blueprints.VPC2 |
| 459 | + """ |
| 460 | + with self.assertRaises(ConstructorError): |
| 461 | + parse(yaml_config) |
| 462 | + |
401 | 463 |
|
402 | 464 | if __name__ == '__main__': |
403 | 465 | unittest.main() |
0 commit comments