Ejemplo n.º 1
0
 def test_execute(self):
     with asynctest.patch('pfun.sql.asyncpg.connect') as connect_mock:
         connect_mock.return_value.close = asynctest.CoroutineMock()
         connect_mock.return_value.execute = asynctest.CoroutineMock(
             return_value='SELECT 1'
         )
         assert sql.execute('select * from users').run(
             HasSQL()
         ) == 'SELECT 1'
Ejemplo n.º 2
0
 def patch_todo(self,
                todo: Todo) -> Effect[sql.HasSQL, PostgresError, Todo]:
     query = '''
         update todos
         set "order" = $1, title = $2, completed = $3
         where id = $4
     '''
     return sql.execute(query, todo.order, todo.title, todo.completed,
                        todo.id).discard_and_then(success(todo))
Ejemplo n.º 3
0
 def delete_todo(self,
                 todo_id: int) -> Effect[sql.HasSQL, PostgresError, None]:
     return sql.execute('delete from todos where id = $1',
                        todo_id).discard_and_then(success(None))
Ejemplo n.º 4
0
 def delete_todos(self) -> Effect[sql.HasSQL, PostgresError, None]:
     return sql.execute('delete from todos').discard_and_then(success(None))