def get_data(): data = [{ 'id': 'joe', 'last_updated': r.time(2014, 6, 3, 'Z') }, { 'id': 'sam', 'last_updated': r.time(2014, 8, 25, 'Z') }] return as_db_and_table('d', 'people', data)
def test_during_closed_right(self, conn): expected = [{'id': 'joe', 'is_during': True}] result = r.db('d').table('people').map( lambda doc: { 'id': doc['id'], 'is_during': doc['last_updated'].during(r.time(2014, 6, 2, 'Z'), r.time(2014, 8, 25, 'Z'), right_bound='closed') }).run(conn) assertEqUnordered(expected, list(result))
def test_during_3(self, conn): expected = [{ 'id': 'joe', 'is_during': True }, { 'id': 'sam', 'is_during': False }] result = r.db('d').table('people').map( lambda doc: { 'id': doc['id'], 'is_during': doc['last_updated'].during(r.time(2014, 6, 3, 'Z'), r.time(2014, 8, 25, 'Z')) }).run(conn) assertEqUnordered(expected, list(result))
def test_error_with_less_than_4_args(self, conn): try: r.db('unimportant').table('very').update({ 'update_time': r.time(2014, 3, 24) }).run(conn) except RqlCompileError as e: err = e assert ('expected between 4 and 7' in err.message.lower())
def test_time_year_month_day_tz(self, conn): r.db('unimportant').table('very').update(lambda doc: doc.merge( {'updated': r.time(2014, 6, 10, 'Z')})).run(conn) result = r.db('unimportant').table('very').get('say_anything').run( conn) update_time = result['updated'] assertEqual(2014, update_time.year) assertEqual(6, update_time.month) assertEqual(10, update_time.day) assert (isinstance(update_time.tzinfo, RqlTzinfo))
def test_time_year_month_day_hour_minute_second_tz(self, conn): r.db('unimportant').table('very').update({ 'updated': r.time(2014, 6, 10, 15, 30, 45, 'Z') }).run(conn) result = r.db('unimportant').table('very').get('say_anything').run( conn) update_time = result['updated'] assertEqual(2014, update_time.year) assertEqual(6, update_time.month) assertEqual(10, update_time.day) assertEqual(15, update_time.hour) assertEqual(30, update_time.minute) assertEqual(45, update_time.second) assert (isinstance(update_time.tzinfo, RqlTzinfo))
def test_filter_during(self, conn): table = r.db('d').table('people') result = table.filter(lambda doc: doc['last_updated'].during( r.time(2014, 6, 1, 'Z'), r.time(2014, 6, 30, 'Z'))).run(conn) result = list(result) assertEqual(2, len(result))