Пример #1
0
    def post(self, environment):
        """Create a new environment."""
        LOG.info("Create environment [env=%s]" % environment)

        db_model = db_api.create_environment(environment.to_dict())

        return Environment(**db_model.to_dict())
Пример #2
0
    def post(self, environment):
        """Create a new environment."""
        LOG.info("Create environment [env=%s]" % environment)
        self._validate_environment(json.loads(wsme_pecan.pecan.request.body),
                                   ['name', 'description', 'variables'])
        db_model = db_api.create_environment(environment.to_dict())

        return Environment(**db_model.to_dict())
Пример #3
0
    def test_resource_to_db_model(self):
        resource = api.Environment(**_convert_vars_to_string(copy.deepcopy(ENVIRONMENT)))

        values = resource.to_dict()

        values["variables"] = json.loads(values["variables"])
        values["created_at"] = datetime.datetime.strptime(values["created_at"], DATETIME_FORMAT)
        values["updated_at"] = datetime.datetime.strptime(values["updated_at"], DATETIME_FORMAT)

        db_model = db.Environment(**values)

        db_api.create_environment(db_model)

        self.assertEqual(values["id"], db_model.id)
        self.assertEqual(values["name"], db_model.name)
        self.assertIsNone(db_model.project_id)
        self.assertEqual(values["description"], db_model.description)
        self.assertDictEqual(values["variables"], db_model.variables)
        self.assertEqual(values["created_at"], db_model.created_at)
        self.assertEqual(values["updated_at"], db_model.updated_at)
Пример #4
0
    def post(self, env):
        """Create a new environment."""
        acl.enforce('environments:create', context.ctx())
        LOG.info("Create environment [env=%s]" % env)

        self._validate_environment(
            json.loads(wsme_pecan.pecan.request.body.decode()),
            ['name', 'description', 'variables'])

        db_model = db_api.create_environment(env.to_dict())

        return Environment.from_dict(db_model.to_dict())
Пример #5
0
    def post(self, env):
        """Create a new environment."""
        LOG.info("Create environment [env=%s]" % env)

        self._validate_environment(
            json.loads(wsme_pecan.pecan.request.body.decode()),
            ['name', 'description', 'variables']
        )

        db_model = db_api.create_environment(env.to_dict())

        return Environment.from_dict(db_model.to_dict())
Пример #6
0
    def test_resource_to_db_model(self):
        resource = api.Environment(
            **_convert_vars_to_string(copy.deepcopy(ENVIRONMENT))
        )

        values = resource.to_dict()

        values['variables'] = json.loads(values['variables'])
        values['created_at'] = datetime.datetime.strptime(
            values['created_at'], DATETIME_FORMAT)
        values['updated_at'] = datetime.datetime.strptime(
            values['updated_at'], DATETIME_FORMAT)

        db_model = db.Environment(**values)

        db_api.create_environment(db_model)

        self.assertEqual(values['id'], db_model.id)
        self.assertEqual(values['name'], db_model.name)
        self.assertIsNone(db_model.project_id)
        self.assertEqual(values['description'], db_model.description)
        self.assertDictEqual(values['variables'], db_model.variables)
        self.assertEqual(values['created_at'], db_model.created_at)
        self.assertEqual(values['updated_at'], db_model.updated_at)
Пример #7
0
    def post(self, env):
        """Create a new environment.

        :param env: Required. Environment structure to create
        """
        acl.enforce('environments:create', context.ctx())

        LOG.debug("Create environment [env=%s]", cut(env))

        self._validate_environment(
            json.loads(wsme_pecan.pecan.request.body.decode()),
            ['name', 'description', 'variables'])

        db_model = db_api.create_environment(env.to_dict())

        return resources.Environment.from_db_model(db_model)