'An API request to create a container including environment
variables results in the existing configuration being updated.'

def test_create_container_with_environment(self):

    saving = self.persistence_service.save(Deployment(nodes={Node(uuid=self.NODE_A_UUID), Node(uuid=self.NODE_B_UUID)}))
    environment = {u'SITES_ENABLED_PATH': u'/etc/nginx/sites-enabled', u'CONFIG_FILE': u'/etc/nginx/nginx.conf'}
    saving.addCallback((lambda _: self.assertResponseCode('POST', '/configuration/containers', {u'node_uuid': self.NODE_A, u'name': u'webserver', u'image': u'nginx', u'environment': environment}, CREATED)))
    def created(_):
        deployment = self.persistence_service.get()
        expected = Deployment(nodes={Node(uuid=self.NODE_A_UUID, applications=WEBSERVER_APPLICATIONS.transform([WEBSERVER_APPLICATION.name, 'environment'], frozenset(environment.items()))), Node(uuid=self.NODE_B_UUID)})
        self.assertEqual(deployment, expected)
    saving.addCallback(created)
    return saving
