def test_environment_configuration(self):
        # Integration test for full environment configuration parsing
        secrets = {
            NeckbeardLoader.VERSION_OPTION: '0.1',
            'environments': {
                'test1': {
                    'foo': 'v_secret1',
                },
                'test2': {
                    'foo': 'v_secret2',
                },
            },
        }
        constants = {
            NeckbeardLoader.VERSION_OPTION: '0.1',
            'environments': {
                'test1': {
                    'foo': 'v_foo1',
                },
                'test2': {
                    'foo': 'v_foo2',
                },
            },
        }
        environments = {
            NeckbeardLoader.VERSION_OPTION: '0.1',
            'test1': {
                'name': 'test1',
                'seed_environment_name': 'test2',
                'aws_nodes': {
                    'ec2': {
                        'web0': {
                            "name": "web0",
                            "unique_id": "web0-{{ node.scaling_index }}",
                            "node_template_name": "web",
                            "seed": {
                                "name": "web",
                            },
                            "service_addons": {
                                "redis": {
                                    "foo": "web0",
                                },
                            },
                        },
                        'web1': {
                            "name": "web1",
                            "unique_id": "web1-{{ node.scaling_index }}",
                            "node_template_name": "web",
                            "seed": {
                                "name": "web",
                            },
                            "service_addons": {
                                "redis": {
                                    "foo": "web1",
                                },
                            },
                            "scaling": {
                                "minimum": 1,
                                "maximum": 2,
                            },
                        },
                    },
                },
            },
            'test2': {
                'name': 'test2',
                'aws_nodes': {
                    'ec2': {
                        'web': {
                            "name": "web",
                            "unique_id": "web-{{ node.scaling_index }}",
                        },
                    },
                },
            },
        }
        node_templates = {
            'ec2': {
                "web": {
                    NeckbeardLoader.VERSION_OPTION: '0.1',
                    "resource_type": "ec2",
                    "node_template_name": "web",
                    "defaults": {
                        "service_addons": {
                            "redis": {
                                "foo": "overridden",
                                "from_template": "v_from_template",
                            },
                            "celery": {
                                "celerybeat": True,
                            },
                        },
                        "constant_foo": "{{ environment.constants.foo }}",
                        "secret_foo": "{{ environment.secrets.foo }}",
                        "s_const_foo": "{{ seed_environment.constants.foo }}",
                        "s_secret_foo": "{{ seed_environment.secrets.foo }}",
                    },
                    "required_overrides": {},
                },
            },
        }
        configuration = ConfigurationManager(
            constants=constants,
            secrets=secrets,
            secrets_tpl={},
            environments=environments,
            node_templates=node_templates,
            scaling_backend=MaxScalingBackend(),
        )
        expanded_configuration = configuration.get_environment_config(
            'test1',
        )
        expected = {
            "ec2": {
                'web0-0': {
                    "name": "web0",
                    "unique_id": "web0-0",
                    "node_template_name": "web",
                    "seed": {
                        "name": "web",
                    },
                    "service_addons": {
                        "redis": {
                            "foo": "web0",
                            "from_template": "v_from_template",
                        },
                        "celery": {
                            "celerybeat": True,
                        },
                    },
                    "constant_foo": "v_foo1",
                    "secret_foo": "v_secret1",
                    "s_const_foo": "v_foo2",
                    "s_secret_foo": "v_secret2",
                },
                'web1-0': {
                    "name": "web1",
                    "unique_id": "web1-0",
                    "node_template_name": "web",
                    "seed": {
                        "name": "web",
                    },
                    "service_addons": {
                        "redis": {
                            "foo": "web1",
                            "from_template": "v_from_template",
                        },
                        "celery": {
                            "celerybeat": True,
                        },
                    },
                    "scaling": {
                        "minimum": 1,
                        "maximum": 2,
                    },
                    "constant_foo": "v_foo1",
                    "secret_foo": "v_secret1",
                    "s_const_foo": "v_foo2",
                    "s_secret_foo": "v_secret2",
                },
                'web1-1': {
                    "name": "web1",
                    "unique_id": "web1-1",
                    "node_template_name": "web",
                    "seed": {
                        "name": "web",
                    },
                    "service_addons": {
                        "redis": {
                            "foo": "web1",
                            "from_template": "v_from_template",
                        },
                        "celery": {
                            "celerybeat": True,
                        },
                    },
                    "scaling": {
                        "minimum": 1,
                        "maximum": 2,
                    },
                    "constant_foo": "v_foo1",
                    "secret_foo": "v_secret1",
                    "s_const_foo": "v_foo2",
                    "s_secret_foo": "v_secret2",
                },
            },
        }
        # Ensure all of the unique nodes exist
        actual_unique_ids = expanded_configuration['ec2'].keys()
        for unique_id in expected['ec2'].keys():
            self.assertTrue(
                actual_unique_ids in unique_id,
                msg="%s not in ec2 resources. Actuals: %s" % (
                    unique_id,
                    actual_unique_ids,
                ),
            )
        # Test that the individual configurations actually match
        for unique_id in expected['ec2'].keys():
            self.assertDictEqual(
                expanded_configuration['ec2'][unique_id],
                expected['ec2'][unique_id],
                msg="Config doesn't match for %s" % unique_id,
            )
dataset/ETHPy150Open winhamwr/neckbeard/neckbeard/tests/test_configuration.py/TestConfigExpansion.test_environment_configuration/swapped operands of `in`