def test_should_page_through_search_results(): session = get_user_session() delete_all_documents() with cassette( 'fixtures/resources/documents/list_search/page_through_search_results.yaml' ): session.documents.create('Underwater basket weaving', 'journal') session.documents.create('Underwater bucket weaving', 'journal') session.documents.create('Overground basket weaving', 'journal') session.documents.create('Underwater basket knitting', 'journal') sleep(3) first_page = session.documents.search('basket').list(page_size=2) assert len(first_page.items) == 2 assert first_page.count == 3 second_page = first_page.next_page assert len(second_page.items) == 1 assert second_page.count == 3 titles = set( [doc.title for doc in first_page.items + second_page.items]) assert titles == { 'Underwater basket weaving', 'Overground basket weaving', 'Underwater basket knitting' }
def test_should_list_search_results_all_view(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/documents/list_search/list_search_results_all_view.yaml'): session.documents.create('Underwater basket weaving', 'journal', publisher='ACM Press') sleep(3) first_page = session.documents.search('basket', view='all').list() assert len(first_page.items) == 1 assert first_page.count == 1 assert first_page.items[0].publisher == 'ACM Press'
def test_should_iterate_through_search_results(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/documents/iter_search/iterate_through_search_results.yaml'): session.documents.create('Underwater basket weaving', 'journal') session.documents.create('Underwater bucket weaving', 'journal') session.documents.create('Overground basket weaving', 'journal') session.documents.create('Underwater basket knitting', 'journal') sleep(3) docs = list(session.documents.search('basket').iter(page_size=2)) titles = set([doc.title for doc in docs]) assert titles == {'Underwater basket weaving', 'Overground basket weaving', 'Underwater basket knitting'}
def test_should_list_documents_modified_since(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/documents/list_documents/modified_since.yaml'): doc1 = create_document(session, 'title 1') sleep(2) create_document(session, 'title 2') create_document(session, 'title 3') page = session.documents.list(modified_since=doc1.created.replace(seconds=+1)) assert len(page.items) == 2 assert page.count == 2 assert page.items[0].title == 'title 2' assert page.items[1].title == 'title 3'
def test_should_list_search_results_all_view(): session = get_user_session() delete_all_documents() with cassette( 'fixtures/resources/documents/list_search/list_search_results_all_view.yaml' ): session.documents.create('Underwater basket weaving', 'journal', publisher='ACM Press') sleep(3) first_page = session.documents.search('basket', view='all').list() assert len(first_page.items) == 1 assert first_page.count == 1 assert first_page.items[0].publisher == 'ACM Press'
def test_should_iterate_through_search_results(): session = get_user_session() delete_all_documents() with cassette( 'fixtures/resources/documents/iter_search/iterate_through_search_results.yaml' ): session.documents.create('Underwater basket weaving', 'journal') session.documents.create('Underwater bucket weaving', 'journal') session.documents.create('Overground basket weaving', 'journal') session.documents.create('Underwater basket knitting', 'journal') sleep(3) docs = list(session.documents.search('basket').iter(page_size=2)) titles = set([doc.title for doc in docs]) assert titles == { 'Underwater basket weaving', 'Overground basket weaving', 'Underwater basket knitting' }
def test_should_list_files_deleted_since(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/files/list_files/deleted_since.yaml'): doc = create_document(session) file1 = doc.attach_file('fixtures/resources/files/basket.txt') file2 = doc.attach_file('fixtures/resources/files/weaving.txt') sleep(1) file1.delete() file2.delete() page = session.files.list(deleted_since=doc.created) assert len(page.items) == 2 assert page.count == 2 assert page.items[0].id == file1.id assert page.items[1].id == file2.id
def test_should_list_files_added_since(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/files/list_files/added_since.yaml'): doc1 = create_document(session) doc1.attach_file('fixtures/resources/files/basket.txt') sleep(2) doc2 = create_document(session) doc2.attach_file('fixtures/resources/files/basket.txt') doc2.attach_file('fixtures/resources/files/weaving.txt') page = session.files.list(added_since=doc2.created.replace(seconds=-1)) assert len(page.items) == 2 assert page.count == 2 assert_basket_file(page.items[0]) assert_weaving_file(page.items[1])
def test_should_list_annotations_modified_since(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/annotations/list_annotations/modified_since.yaml'): doc = create_document(session, 'title 1') file = doc.attach_file('fixtures/resources/files/basket.txt') annotation = file.add_sticky_note("annotation 1", 100, 200, 1) sleep(2) file.add_sticky_note("annotation 2", 100, 200, 1) file.add_sticky_note("annotation 3", 100, 200, 1) page = session.annotations.list(modified_since=annotation.created.replace(seconds=+1)) assert len(page.items) == 2 assert page.count == 2 assert page.items[0].text == 'annotation 2' assert page.items[1].text == 'annotation 3'
def test_should_list_documents_deleted_since(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/documents/list_documents/deleted_since.yaml'): doc1 = create_document(session, 'title 1') doc2 = create_document(session, 'title 2') doc3 = create_document(session, 'title 3') doc1.delete() sleep(2) doc2.delete() doc3.delete() page = session.documents.list(deleted_since=doc3.created.replace(seconds=+1)) assert len(page.items) == 2 assert page.count == 2 assert page.items[0].id == doc2.id assert page.items[1].id == doc3.id
def test_should_page_through_search_results(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/documents/list_advanced_search/page_through_search_results.yaml'): session.documents.create('Underwater basket weaving', 'journal', source='Journal of Submarine Bambrology') session.documents.create('Underwater bucket weaving', 'journal', source='Journal of Submarine Bucketology') session.documents.create('Overground basket weaving', 'journal', source='Journal of Aeronautical Bambrology') session.documents.create('Underwater basket knitting', 'journal', source='Journal of Submarine Woolonomics') sleep(3) first_page = session.documents.advanced_search(title='basket', source='submarine').list(page_size=1) assert len(first_page.items) == 1 assert first_page.count == 2 second_page = first_page.next_page assert len(second_page.items) == 1 assert second_page.count == 2 titles = set([doc.title for doc in first_page.items + second_page.items]) assert titles == {'Underwater basket weaving', 'Underwater basket knitting'}
def test_should_page_through_search_results(): session = get_user_session() delete_all_documents() with cassette('fixtures/resources/documents/list_search/page_through_search_results.yaml'): session.documents.create('Underwater basket weaving', 'journal') session.documents.create('Underwater bucket weaving', 'journal') session.documents.create('Overground basket weaving', 'journal') session.documents.create('Underwater basket knitting', 'journal') sleep(3) first_page = session.documents.search('basket').list(page_size=2) assert len(first_page.items) == 2 assert first_page.count == 3 second_page = first_page.next_page assert len(second_page.items) == 1 assert second_page.count == 3 titles = set([doc.title for doc in first_page.items + second_page.items]) assert titles == {'Underwater basket weaving', 'Overground basket weaving', 'Underwater basket knitting'}
def test_should_list_annotations_modified_since(): session = get_user_session() delete_all_documents() with cassette( 'fixtures/resources/annotations/list_annotations/modified_since.yaml' ): doc = create_document(session, 'title 1') file = doc.attach_file('fixtures/resources/files/basket.txt') annotation = file.add_sticky_note("annotation 1", 100, 200, 1) sleep(2) file.add_sticky_note("annotation 2", 100, 200, 1) file.add_sticky_note("annotation 3", 100, 200, 1) page = session.annotations.list( modified_since=annotation.created.replace(seconds=+1)) assert len(page.items) == 2 assert page.count == 2 assert page.items[0].text == 'annotation 2' assert page.items[1].text == 'annotation 3'
def test_should_page_through_search_results(): session = get_user_session() delete_all_documents() with cassette( 'fixtures/resources/documents/list_advanced_search/page_through_search_results.yaml' ): session.documents.create('Underwater basket weaving', 'journal', source='Journal of Submarine Bambrology') session.documents.create('Underwater bucket weaving', 'journal', source='Journal of Submarine Bucketology') session.documents.create('Overground basket weaving', 'journal', source='Journal of Aeronautical Bambrology') session.documents.create('Underwater basket knitting', 'journal', source='Journal of Submarine Woolonomics') sleep(3) first_page = session.documents.advanced_search( title='basket', source='submarine').list(page_size=1) assert len(first_page.items) == 1 assert first_page.count == 2 second_page = first_page.next_page assert len(second_page.items) == 1 assert second_page.count == 2 titles = set( [doc.title for doc in first_page.items + second_page.items]) assert titles == { 'Underwater basket weaving', 'Underwater basket knitting' }