Ejemplo n.º 1
0
 def create(self, pool_ticket: PoolTicket) -> Pool:
     """ Create pool
     Args:
         pool_ticket (PoolTicket):       Contains generated access ID and secret
     Returns:
         Pool
     """
     result = self.__pool_data.insert(
         const=pool_ticket.get_const(),
         status_id=self.__statuses.ACTIVE.get_id(),
         access_id=pool_ticket.get_access_id(),
         secret=self.__encrypt_secret(pool_ticket.get_secret())
     )
     if not result.get_status():
         raise PoolCreateError("Could not create pool")
     return self.get(result.get_insert_id())
Ejemplo n.º 2
0
 def test_create_creates_pool(self):
     pool_ticket = PoolTicket("POOL_NAME")
     pool_data = {
         "id": 1,
         "uuid": "ERT-123",
         "const": pool_ticket.get_const(),
         "status_id": self.active_status.get_id()
     }
     self.postgres_conn_manager.insert = MagicMock(
         return_value=Result(True))
     self.postgres_conn_manager.select = MagicMock(
         return_value=Result(True, "", [pool_data]))
     pool = self.pool_manager.create(pool_ticket)
     self.postgres_conn_manager.insert.assert_called_once()
     self.postgres_conn_manager.select.assert_called_once()
     self.assertEqual(pool_data["id"], pool.get_id())
     self.assertEqual(pool_data["uuid"], pool.get_uuid())
     self.assertEqual(pool_data["const"], pool.get_const())
     self.assertEqual(pool_data["status_id"], pool.get_status().get_id())