Exemplo n.º 1
0
def setup(session_with_profile_loaded):
    """
    Like session_with_profile_loaded, but also:
      * Added are:
        * A deck `test_deck`
        * A model `test_model` with fields `filed1` and `field2`
          and two cards per note
        * Two notes with two valid cards each using the above deck and model
      * Edit dialog is registered with dialog manager
      * Any dialogs, if open, are safely closed on exit
    """
    Edit.register_with_anki()
    yield set_up_test_deck_and_test_model_and_two_notes()
    close_all_dialogs_and_wait_for_them_to_run_closing_callbacks()
Exemplo n.º 2
0
    def test_navigation(self, setup):
        dialog = Edit.open_dialog_and_show_note_with_id(setup.note1_id)
        Edit.open_dialog_and_show_note_with_id(setup.note2_id)

        dialog.show_previous()
        assert dialog.note.id == setup.note1_id

        dialog.show_previous()
        assert dialog.note.id == setup.note1_id

        dialog.show_next()
        assert dialog.note.id == setup.note2_id

        dialog.show_next()
        assert dialog.note.id == setup.note2_id
Exemplo n.º 3
0
    def test_selects_cards_of_note_before_last_after_previous_button_pressed(
            self, setup):
        Edit.open_dialog_and_show_note_with_id(setup.note1_id)
        dialog = Edit.open_dialog_and_show_note_with_id(setup.note2_id)

        def verify_that_the_table_shows_note2_cards_then_note1_cards():
            get_dialog_instance("Browser").table.select_all()
            assert {*self.get_selected_card_ids()[:2]
                    } == {*setup.note2_card_ids}
            assert {*self.get_selected_card_ids()[2:]
                    } == {*setup.note1_card_ids}

        dialog.show_previous()
        dialog.show_browser()
        assert {*self.get_selected_card_ids()} == {*setup.note1_card_ids}
        verify_that_the_table_shows_note2_cards_then_note1_cards()

        dialog.show_next()
        dialog.show_browser()
        assert {*self.get_selected_card_ids()} == {*setup.note2_card_ids}
        verify_that_the_table_shows_note2_cards_then_note1_cards()
Exemplo n.º 4
0
    def dialog(self, setup):
        edit_dialog = Edit.open_dialog_and_show_note_with_id(setup.note1_id)
        preview_dialog: DecentPreviewer = edit_dialog.show_preview()

        def press_next_button(times=0):
            for _ in range(times):
                preview_dialog._last_render = 0  # render without delay
                preview_dialog._on_next()

        preview_dialog.press_next_button = press_next_button

        yield preview_dialog
Exemplo n.º 5
0
    def test_selects_cards_of_last_note(self, setup):
        Edit.open_dialog_and_show_note_with_id(setup.note1_id)
        Edit.open_dialog_and_show_note_with_id(setup.note2_id).show_browser()

        assert {*self.get_selected_card_ids()} == {*setup.note2_card_ids}
Exemplo n.º 6
0
 def test_dialog_opens(self, setup):
     dialog = Edit.open_dialog_and_show_note_with_id(setup.note1_id)
     dialog.show_browser()
Exemplo n.º 7
0
def test_edit_dialog_fails_to_open_with_invalid_note(setup):
    with pytest.raises(Exception):
        Edit.open_dialog_and_show_note_with_id(123)
Exemplo n.º 8
0
def test_edit_dialog_opens_only_once(setup):
    dialog1 = Edit.open_dialog_and_show_note_with_id(setup.note1_id)
    dialog2 = Edit.open_dialog_and_show_note_with_id(setup.note1_id)
    assert dialog1 is dialog2
Exemplo n.º 9
0
def test_edit_dialog_opens(setup):
    Edit.open_dialog_and_show_note_with_id(setup.note1_id)
Exemplo n.º 10
0
 def dialog(self, setup):
     Edit.open_dialog_and_show_note_with_id(setup.note1_id)
     yield Edit.open_dialog_and_show_note_with_id(setup.note2_id)
Exemplo n.º 11
0
 def test_old_note_reopened(self, setup):
     Edit.open_dialog_and_show_note_with_id(setup.note1_id)
     Edit.open_dialog_and_show_note_with_id(setup.note2_id)
     Edit.open_dialog_and_show_note_with_id(setup.note1_id)
     assert history.note_ids == [setup.note2_id, setup.note1_id]
Exemplo n.º 12
0
 def test_single_note(self, setup):
     assert history.note_ids == []
     Edit.open_dialog_and_show_note_with_id(setup.note1_id)
     assert history.note_ids == [setup.note1_id]
Exemplo n.º 13
0
 def test_addon_buttons_get_disabled_enabled(self, setup, manipulator):
     Edit.open_dialog_and_show_note_with_id(setup.note2_id)
     manipulator.wait_until_toolbar_buttons_are_ready()
     assert manipulator.is_button_disabled("previous") is False
     assert manipulator.is_button_disabled("next") is True
Exemplo n.º 14
0
 def manipulator(self, setup):
     dialog = Edit.open_dialog_and_show_note_with_id(setup.note1_id)
     return JavascriptDialogButtonManipulator(dialog)
Exemplo n.º 15
0
 def test_opens(self, setup):
     edit_dialog = Edit.open_dialog_and_show_note_with_id(setup.note1_id)
     edit_dialog.show_preview()