def test_should_iterate_through_files():
    session = get_user_session()
    delete_all_documents()

    with cassette('fixtures/resources/files/iter_files/iterate_through_files.yaml'):
        doc1 = create_document(session)
        doc2 = create_document(session)

        doc1.attach_file('fixtures/resources/files/basket.txt')
        doc1.attach_file('fixtures/resources/files/weaving.txt')
        doc2.attach_file('fixtures/resources/files/basket.txt')

        files = list(islice(session.files.iter(page_size=2), 3))

        assert len(files) == 3
        assert_basket_file(files[0])
        assert_weaving_file(files[1])
        assert_basket_file(files[2])
Ejemplo n.º 2
0
def test_should_iterate_through_files():
    session = get_user_session()
    delete_all_documents()

    with cassette(
            'fixtures/resources/files/iter_files/iterate_through_files.yaml'):
        doc1 = create_document(session)
        doc2 = create_document(session)

        doc1.attach_file('fixtures/resources/files/basket.txt')
        doc1.attach_file('fixtures/resources/files/weaving.txt')
        doc2.attach_file('fixtures/resources/files/basket.txt')

        files = list(islice(session.files.iter(page_size=2), 3))

        assert len(files) == 3
        assert_basket_file(files[0])
        assert_weaving_file(files[1])
        assert_basket_file(files[2])
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_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_page_through_files():
    session = get_user_session()
    delete_all_documents()

    with cassette('fixtures/resources/files/list_files/page_through_files.yaml'):
        doc1 = create_document(session)
        doc2 = create_document(session)

        doc1.attach_file('fixtures/resources/files/basket.txt')
        doc1.attach_file('fixtures/resources/files/weaving.txt')
        doc2.attach_file('fixtures/resources/files/basket.txt')

        first_page = session.files.list(page_size=2)
        assert len(first_page.items) == 2
        assert first_page.count == 3

        assert_basket_file(first_page.items[0])
        assert_weaving_file(first_page.items[1])

        second_page = first_page.next_page
        assert len(second_page.items) == 1
        assert second_page.count == 3
        assert_basket_file(second_page.items[0])
def test_should_page_through_files():
    session = get_user_session()
    delete_all_documents()

    with cassette(
            'fixtures/resources/files/list_files/page_through_files.yaml'):
        doc1 = create_document(session)
        doc2 = create_document(session)

        doc1.attach_file('fixtures/resources/files/basket.txt')
        doc1.attach_file('fixtures/resources/files/weaving.txt')
        doc2.attach_file('fixtures/resources/files/basket.txt')

        first_page = session.files.list(page_size=2)
        assert len(first_page.items) == 2
        assert first_page.count == 3

        assert_basket_file(first_page.items[0])
        assert_weaving_file(first_page.items[1])

        second_page = first_page.next_page
        assert len(second_page.items) == 1
        assert second_page.count == 3
        assert_basket_file(second_page.items[0])