def test_rename_deletes_auth_tickets(self, service, user, db_session, factories): ids = [factories.AuthTicket(user=user).id for _ in xrange(3)] service.rename(user, 'panda') count = db_session.query(models.AuthTicket).filter(models.AuthTicket.id.in_(ids)).count() assert count == 0
def test_annotations_count_returns_count_of_annotations(self, db_session, document): bucket = bucketing.DocumentBucket(document) for _ in xrange(7): annotation = factories.Annotation() bucket.append(annotation) assert bucket.annotations_count == 7
def test_append_appends_the_annotation(self, document): bucket = bucketing.DocumentBucket(document) annotations = [] for _ in xrange(7): annotation = factories.Annotation() annotations.append(annotation) bucket.append(annotation) assert bucket.annotations == annotations
def test_eq(self, document): bucket_1 = bucketing.DocumentBucket(document) bucket_2 = bucketing.DocumentBucket(document) for _ in xrange(5): annotation = factories.Annotation() bucket_1.append(annotation) bucket_2.append(annotation) assert bucket_1 == bucket_2
def _fetch_windows(session, column, chunksize=100): updated = (session.query(column).execution_options( stream_results=True).order_by(column.desc()).all()) count = len(updated) windows = [ Window(start=updated[min(x + chunksize, count) - 1].updated, end=updated[x].updated) for x in xrange(0, count, chunksize) ] return windows
def _fetch_windows(session, column, chunksize=100): updated = session.query(column). \ execution_options(stream_results=True). \ order_by(column.desc()).all() count = len(updated) windows = [Window(start=updated[min(x+chunksize, count)-1].updated, end=updated[x].updated) for x in xrange(0, count, chunksize)] return windows
def flags(self, factories): return [factories.Flag() for _ in xrange(3)]