@@ -0,0 +1,2666 @@
+from unittest.mock import patch%0A%0Afrom osfclient.models import OSFCore%0Afrom osfclient.models import File%0Afrom osfclient.models import Folder%0A%0Afrom osfclient.tests import fake_responses%0Afrom osfclient.tests.mocks import FakeResponse%0A%0A_files_url = 'https://api.osf.io/v2//nodes/f3szh/files/osfstorage/foo123'%0A%0A%0A@patch.object(OSFCore, '_get')%0Adef test_iterate_files(OSFCore_get):%0A    store = Folder(%7B%7D)%0A    store._files_url = _files_url%0A%0A    json = fake_responses.files_node('f3szh', 'osfstorage',%0A                                     %5B'foo/hello.txt', 'foo/bye.txt'%5D)%0A    response = FakeResponse(200, json)%0A    OSFCore_get.return_value = response%0A%0A    files = list(store.files)%0A%0A    assert len(files) == 2%0A    for file_ in files:%0A        assert isinstance(file_, File)%0A        assert file_.session == store.session%0A%0A    OSFCore_get.assert_called_once_with(%0A        'https://api.osf.io/v2//nodes/f3szh/files/osfstorage/foo123')%0A%0A%0A@patch.object(OSFCore, '_get')%0Adef test_iterate_folders(OSFCore_get):%0A    store = Folder(%7B%7D)%0A    store._files_url = _files_url%0A%0A    json = fake_responses.files_node('f3szh', 'osfstorage',%0A                                     folder_names=%5B'foo/bar', 'foo/baz'%5D)%0A    response = FakeResponse(200, json)%0A    OSFCore_get.return_value = response%0A%0A    folders = list(store.folders)%0A%0A    assert len(folders) == 2%0A    for folder in folders:%0A        assert isinstance(folder, Folder)%0A        assert folder.session == store.session%0A        assert folder.name in ('foo/bar', 'foo/baz')%0A%0A    OSFCore_get.assert_called_once_with(%0A        'https://api.osf.io/v2//nodes/f3szh/files/osfstorage/foo123')%0A%0A%0Adef test_iterate_files_and_folders():%0A    # check we do not attempt to recurse into the subfolders%0A    store = Folder(%7B%7D)%0A    store._files_url = _files_url%0A%0A    json = fake_responses.files_node('f3szh', 'osfstorage',%0A                                     file_names=%5B'hello.txt', 'bye.txt'%5D,%0A                                     folder_names=%5B'bar'%5D)%0A    top_level_response = FakeResponse(200, json)%0A%0A    def simple_OSFCore_get(url):%0A        if url == store._files_url:%0A            return top_level_response%0A        else:%0A            print(url)%0A            raise ValueError()%0A%0A    with patch.object(OSFCore, '_get',%0A                      side_effect=simple_OSFCore_get) as mock_osf_get:%0A        files = list(store.files)%0A%0A    assert len(files) == 2%0A    for file_ in files:%0A        assert isinstance(file_, File)%0A        assert file_.session == store.session%0A        assert file_.name in ('hello.txt', 'bye.txt')%0A%0A    # check we did not try to recurse into subfolders%0A    expected = %5B((_files_url,),)%5D%0A    assert mock_osf_get.call_args_list == expected%0A

Add test of Folder instances