Example #1
0
def test_picking_n5_json_file_returns_directory_path(tmp_n5_file: Path):
    dialog = ImageFileDialog(None)
    dialog.setDirectory(str(tmp_n5_file))
    dialog.selectFile("attributes.json")

    QTimer.singleShot(SINGLE_SHOT_DELAY, dialog.accept)
    assert dialog.getSelectedPaths() == [tmp_n5_file]
Example #2
0
def test_picking_n5_json_file_returns_directory_path(tmp_n5_file: Path):
    dialog = ImageFileDialog(None)
    dialog.setDirectory(str(tmp_n5_file))
    dialog.selectFile("attributes.json")

    def handle_dialog():
        while not dialog.isVisible():
            QApplication.processEvents()

        dialog.accept()

    QTimer.singleShot(0, handle_dialog)

    assert dialog.getSelectedPaths() == [tmp_n5_file]
Example #3
0
def test_picking_file_updates_default_image_directory_to_previously_used(
        image: Path, tmp_preferences):
    dialog = ImageFileDialog(None)
    dialog.selectFile(image.as_posix())

    QTimer.singleShot(SINGLE_SHOT_DELAY, dialog.accept)
    assert dialog.getSelectedPaths() == [image]

    with open(tmp_preferences, "rb") as f:
        assert pickle.load(f) == {
            dialog.preferences_group: {
                dialog.preferences_setting: image.as_posix()
            }
        }
Example #4
0
def test_picking_file_updates_default_image_directory_to_previously_used(
        image: Path, tmp_preferences):
    dialog = ImageFileDialog(None)
    dialog.selectFile(image.as_posix())

    def handle_dialog():
        while not dialog.isVisible():
            QApplication.processEvents()

        dialog.accept()

    QTimer.singleShot(0, handle_dialog)
    assert dialog.getSelectedPaths() == [image]

    with open(tmp_preferences, "r") as f:
        assert json.load(f) == {
            "DataSelection": {
                "recent image": image.as_posix()
            }
        }