Ejemplo n.º 1
0
    def test_resource(self):
        resource = api.Environment(**copy.deepcopy(ENVIRONMENT))

        self._assert_dict_equal(
            copy.deepcopy(ENVIRONMENT),
            resource.to_dict()
        )
Ejemplo n.º 2
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)