def test_folder_contents_prepare_folder_method(
    monkeypatch,
    folder_contents_object,
    vdr_folder_subfolders,
    vdr_folder_files_list,
    mock_get_path,
    vdr_folder_detail,
):

    folder = folder_contents_object(123, "root/next level/SiteName/Folder1",
                                    "SiteName/Folder1")

    monkeypatch.setattr(utils, "get_sub_folders_of_single_folder",
                        vdr_folder_subfolders)
    monkeypatch.setattr(os.path, "join", mock_get_path)
    monkeypatch.setattr(utils, "get_single_folder_details", vdr_folder_detail)
    monkeypatch.setattr(utils, "get_files_in_single_folder",
                        vdr_folder_files_list)

    folder.prepare_folder()

    assert folder.has_files()
    assert folder.has_subfolders()
    assert folder.vdr_path == "SiteName/Folder1/Just a folder name"
    assert folder.local_path == "root/next level/SiteName/Folder1/Just a folder name"
def test_folder_contents_has_subfolders_when_no_subfolders(
        folder_contents_object):

    folder = folder_contents_object(123, "root/next level/SiteName/Folder1",
                                    "SiteName/Folder1")

    assert not folder.has_subfolders()
def test_folder_contents_object_updates_vdr_path_no_vdr_path_supplied(
        monkeypatch, folder_contents_object, vdr_folder_detail):

    monkeypatch.setattr(utils, "get_single_folder_details", vdr_folder_detail)

    folder = folder_contents_object(123)
    folder._get_folder_details()
    folder._update_vdr_path()
    assert folder.vdr_path == "Just a folder name"
def test_folder_contents_object_updates_local_path_no_local_path_supplied(
        monkeypatch, folder_contents_object, vdr_folder_detail, mock_get_path):

    monkeypatch.setattr(utils, "get_single_folder_details", vdr_folder_detail)
    monkeypatch.setattr(os.path, "join", mock_get_path)

    folder = folder_contents_object(123, "", "SiteName/Folder1")
    folder._get_folder_details()
    folder._update_local_path()
    assert folder.local_path == "root/next level/SiteName/Folder1/Just a folder name"
def test_folder_contents_object_get_folder_details(monkeypatch,
                                                   folder_contents_object,
                                                   vdr_folder_detail):

    monkeypatch.setattr(utils, "get_single_folder_details", vdr_folder_detail)

    folder = folder_contents_object(123, "Local/Project/SiteName/Folder1",
                                    "SiteName/Folder1")
    folder._get_folder_details()
    assert folder.folder_details
def test_folder_contents_object_updates_vdr_path(monkeypatch,
                                                 folder_contents_object,
                                                 vdr_folder_detail):

    folder = folder_contents_object(123, "root/next level/SiteName/Folder1",
                                    "SiteName/Folder1")
    monkeypatch.setattr(utils, "get_single_folder_details", vdr_folder_detail)
    folder._get_folder_details()
    folder._update_vdr_path()
    assert folder.vdr_path == "SiteName/Folder1/Just a folder name"
def test_folder_contents_object_initialize_report_writer(
        monkeypatch, folder_contents_object, vdr_folder_detail):

    monkeypatch.setattr(utils, "get_single_folder_details", vdr_folder_detail)

    folder = folder_contents_object(123, "Local/Project/SiteName/Folder1",
                                    "SiteName/Folder1")
    folder._get_folder_details()
    folder._initialize_report_writer()
    assert folder.report is not None
    assert folder.report_id == 1
def test_folder_contents_object_init(folder_contents_object):

    folder = folder_contents_object(123, "Local/Project/SiteName/Folder1",
                                    "SiteName/Folder1")
    assert folder.folder_id == 123
    assert folder.user.id == 1
    assert folder.local_path == "Local/Project/SiteName/Folder1"
    assert folder.vdr_path == "SiteName/Folder1"
    assert not folder.folder_details
    assert not folder.subfolders
    assert not folder.files
def test_folder_contents_get_files(
    monkeypatch,
    folder_contents_object,
    vdr_folder_files_list,
    mock_get_path,
    vdr_folder_detail,
):
    folder = folder_contents_object(123, "root/next level/SiteName/Folder1",
                                    "SiteName/Folder1")

    monkeypatch.setattr(utils, "get_files_in_single_folder",
                        vdr_folder_files_list)
    monkeypatch.setattr(os.path, "join", mock_get_path)
    monkeypatch.setattr(utils, "get_single_folder_details", vdr_folder_detail)

    folder._get_folder_details()
    folder._update_vdr_path()
    folder._update_local_path()
    folder._get_files()
    assert folder.files