def test_soft_deletes_are_not_retrieved_from_builder_helpers(self): self.create_users() count = 0 query = SoftDeletesTestUser.query() for users in query.chunk(2): count += len(users) self.assertEqual(1, count) query = SoftDeletesTestUser.query() self.assertEqual(1, len(query.lists("email"))) Paginator.current_page_resolver(lambda: 1) query = SoftDeletesTestUser.query() self.assertEqual(1, len(query.paginate(2).items)) Paginator.current_page_resolver(lambda: 1) query = SoftDeletesTestUser.query() self.assertEqual(1, len(query.simple_paginate(2).items)) self.assertEqual( 0, SoftDeletesTestUser.where("email", "*****@*****.**").increment("id") ) self.assertEqual( 0, SoftDeletesTestUser.where("email", "*****@*****.**").decrement("id") )
def init_app(self, app): if 'ORATOR_DATABASES' not in app.config: raise RuntimeError('Missing "ORATOR_DATABASES" configuration') self._config = app.config['ORATOR_DATABASES'] self.Model.set_connection_resolver(self) # Setting current page resolver def current_page_resolver(): return int(request.args.get('page', 1)) Paginator.current_page_resolver(current_page_resolver) self.init_commands(app)
def init_app(self, app): if 'ORATOR_DATABASES' not in app.config: raise RuntimeError('Missing "ORATOR_DATABASES" configuration') # Register request hooks self.register_handlers(app) # Getting config databases self._config = app.config['ORATOR_DATABASES'] # Initializing database manager self._db = self._manager_class(self._config) self.Model.set_connection_resolver(self._db) # Setting current page resolver Paginator.current_page_resolver(self._current_page_resolver) # Setting commands self.init_commands()
def init_app(self, app): if 'ORATOR_DATABASES' not in app.config: raise RuntimeError('Missing "ORATOR_DATABASES" configuration') # Register request hooks self.register_handlers(app) # Getting config databases self._config = app.config['ORATOR_DATABASES'] # Initializing database manager self._db = self._manager_class(self._config) self.Model.set_connection_resolver(self._db) # Setting current page resolver Paginator.current_page_resolver(self._current_page_resolver) # Setting commands self.init_commands()
def test_soft_deletes_are_not_retrieved_from_builder_helpers(self): self.create_users() count = 0 query = SoftDeletesTestUser.query() for users in query.chunk(2): count += len(users) self.assertEqual(1, count) query = SoftDeletesTestUser.query() self.assertEqual(1, len(query.lists('email'))) Paginator.current_page_resolver(lambda: 1) query = SoftDeletesTestUser.query() self.assertEqual(1, len(query.paginate(2).items)) Paginator.current_page_resolver(lambda: 1) query = SoftDeletesTestUser.query() self.assertEqual(1, len(query.simple_paginate(2).items)) self.assertEqual(0, SoftDeletesTestUser.where('email', '*****@*****.**').increment('id')) self.assertEqual(0, SoftDeletesTestUser.where('email', '*****@*****.**').decrement('id'))
def test_current_page_resolver(self): def current_page_resolver(): return 7 Paginator.current_page_resolver(current_page_resolver) self.assertEqual(7, Paginator.resolve_current_page())