Beispiel #1
0
 def post(self, data):
     """Create a new account."""
     conn = pecan.request.db_conn
     try:
         account = db_models.Account(**data.as_dict())
         return conn.create_account(request.context, account)
     except Exception:
         LOG.exception('Fail to create account: %s' % data.as_dict())
         raise exception.AccountCreateFailed(user_id=data.user_id,
                                             domain_id=data.domain_id)
Beispiel #2
0
    def setUp(self):
        super(self.__class__, self).setUp()

        self.account = db_models.Account(user_id=self.user_id,
                                         project_id=self.project_id,
                                         domain_id=self.domain_id,
                                         balance=self.balance,
                                         frozen_balance=self.frozen_balance,
                                         consumption=self.consumption,
                                         level=self.level,
                                         inviter=self.inviter,
                                         sales_id=self.sales_id)
        self.dbconn.create_account(self.context, self.account)

        self.project = db_models.Project(user_id=self.user_id,
                                         project_id=self.project_id,
                                         domain_id=self.domain_id,
                                         consumption=0)
        self.dbconn.create_project(self.context, self.project)
        self.user_project = copy.deepcopy(self.project)

        self.addCleanup(delete_all_rows, sql_models.UserProject)
        self.addCleanup(delete_all_rows, sql_models.Project)
        self.addCleanup(delete_all_rows, sql_models.Account)