def test_query_correctly_handled(self): self.Artist.create(name='John') self.Artist.create(name='Andrei') with get_conn() as conn: # order_by should be correctly handled by self.Artist results = list(self.Artist.order_by('name').run(conn)) assert results[0]['name'] == 'Andrei' assert results[1]['name'] == 'John'
def setUp(self): super(DbBaseTestCase, self).setUp() # Create new database and switch to it try: with get_conn() as conn: r.db_create('testing').run(conn) conn.use('testing') except RqlDriverError: raise unittest.SkipTest('RethinkDB is unaccessible')
def test_custom_query_correctly_handled(self): a = self.Artist() a.save() a['tastes'].create(name='House') a['tastes'].create(name='Classical') with get_conn() as conn: # order_by should be correctly handled by a['tastes'] results = list(a['tastes'].order_by('name').run(conn)) assert results[0]['name'] == 'Classical' assert results[1]['name'] == 'House'
def test_custom_query_correctly_handled(self): a = self.Artist() a.save() a['songs'].create(name='Sandstorm') a['songs'].create(name='Rocket') with get_conn() as conn: # order_by should be correctly handled by a['songs'] results = list(a['songs'].order_by('name').run(conn)) assert results[0]['name'] == 'Rocket' assert results[1]['name'] == 'Sandstorm'
def tearDown(self): super(DbBaseTestCase, self).tearDown() # Drop test database with get_conn() as conn: r.db_drop('testing').run(conn)