コード例 #1
0
 def test_create_min_max_body_item_called(self, patch_tk, monkeypatch):
     calls = []
     monkeypatch.setattr(guiwidgets.SearchMovieGUI,
                         'create_min_max_body_item',
                         lambda *args: calls.append(args))
     with self.movie_context() as movie_gui:
         assert calls == [
             (movie_gui,
              TtkFrame(parent=TtkFrame(parent=DummyTk(), padding=''),
                       padding=(10, 25, 10, 0)), 'year', 'Year', 1),
             (movie_gui,
              TtkFrame(parent=TtkFrame(parent=DummyTk(), padding=''),
                       padding=(10, 25, 10, 0)), 'minutes',
              'Length (minutes)', 3),
         ]
コード例 #2
0
 def test_search_button_created(self, patch_tk):
     with self.movie_context() as movie_gui:
         button = movie_gui.parent.children[0].children[1].children[0]
         assert button == TtkButton(parent=TtkFrame(
             parent=TtkFrame(parent=DummyTk()), padding=(5, 5, 10, 10)),
                                    text='Search',
                                    command=movie_gui.search)
コード例 #3
0
 def test_create_entry_creates_ttk_entry(self, patch_tk):
     with self.movie_context() as movie_gui:
         assert movie_gui.entry_fields['title'].widget == TtkEntry(
             parent=TtkFrame(parent=TtkFrame(parent=DummyTk(), padding=''),
                             padding=(10, 25, 10, 0)),
             textvariable=TkStringVar(),
             width=36)
コード例 #4
0
 def test_delete_button_created(self, patch_tk, class_fixtures):
     with self.movie_context() as movie_gui:
         button = movie_gui.parent.children[0].children[1].children[1]
         assert button == TtkButton(parent=TtkFrame(
             parent=TtkFrame(parent=DummyTk()), padding=(5, 5, 10, 10)),
                                    text='Delete',
                                    command=movie_gui.delete)
コード例 #5
0
 def test_create_simple_body_item_called(self, patch_tk, monkeypatch):
     calls = []
     monkeypatch.setattr(guiwidgets.SearchMovieGUI, 'create_body_item',
                         lambda *args: calls.append(args))
     monkeypatch.setattr(guiwidgets, 'focus_set', lambda *args: None)
     with self.movie_context() as movie_gui:
         assert calls == [
             (movie_gui,
              TtkFrame(parent=TtkFrame(parent=DummyTk(), padding=''),
                       padding=(10, 25, 10, 0)), 'title', 'Title', 0),
             (movie_gui,
              TtkFrame(parent=TtkFrame(parent=DummyTk(), padding=''),
                       padding=(10, 25, 10, 0)), 'director', 'Director', 2),
             (movie_gui,
              TtkFrame(parent=TtkFrame(parent=DummyTk(), padding=''),
                       padding=(10, 25, 10, 0)), 'notes', 'Notes', 4),
         ]
コード例 #6
0
    def test_callback_raises_movie_search_found_nothing(
            self, patch_tk, monkeypatch):
        # noinspection PyUnusedLocal
        def callback(*args):
            raise exception.DatabaseSearchFoundNothing

        messagebox_calls = []
        monkeypatch.setattr(guiwidgets, 'gui_messagebox',
                            lambda *args: messagebox_calls.append(args))
        tags = []
        # noinspection PyTypeChecker
        movie_gui = guiwidgets.SearchMovieGUI(DummyTk(), callback, tags)
        movie_gui.search()
        assert messagebox_calls == [
            (DummyTk(), 'No matches',
             'There are no matching movies in the database.')
        ]
コード例 #7
0
 def test_min_max_body_item_frame_created(self, patch_tk):
     with self.movie_context() as movie_gui:
         outerframe = movie_gui.parent.children[0]
         body_frame = outerframe.children[0]
         year_max_min_frame = body_frame.children[3]
         assert year_max_min_frame == TtkFrame(parent=TtkFrame(
             parent=TtkFrame(parent=DummyTk(), padding=''),
             padding=(10, 25, 10, 0)),
                                               padding=(2, 0))
コード例 #8
0
 def test_body_item_ttk_label_called(self, patch_tk):
     with self.movie_context() as movie_gui:
         outerframe = movie_gui.parent.children[0]
         body_frame = outerframe.children[0]
         first_label = body_frame.children[0]
         assert first_label == TtkLabel(parent=TtkFrame(
             parent=TtkFrame(parent=DummyTk(), padding=''),
             padding=(10, 25, 10, 0)),
                                        text='Title',
                                        padding='')
コード例 #9
0
 def test_min_max_body_item_ttk_label_called(self, patch_tk):
     with self.movie_context() as movie_gui:
         outerframe = movie_gui.parent.children[0]
         body_frame = outerframe.children[0]
         year_label = body_frame.children[2]
         assert year_label == TtkLabel(parent=TtkFrame(
             parent=TtkFrame(parent=DummyTk(), padding=''),
             padding=(10, 25, 10, 0)),
                                       text='Year (min, max)',
                                       padding='')
コード例 #10
0
 def test_create_tag_treeview_called(self, patch_tk, patch_movie_treeview):
     with self.movie_context():
         assert treeview_call[0][1] == guiwidgets.TAG_TREEVIEW_INTERNAL_NAME
         assert treeview_call[0][2] == TtkFrame(parent=TtkFrame(
             parent=DummyTk(), padding=''),
                                                padding=(10, 25, 10, 0))
         assert treeview_call[0][3] == 5
         assert treeview_call[0][4] == 0
         assert treeview_call[0][5] == 'Select tags'
         assert treeview_call[0][6] == ('test tag 1', 'test tag 2')
         assert treeview_call[0][7]('test signal') == 'test signal'
コード例 #11
0
 def test_treeview_called(self, patch_tk):
     with self.select_movie_context() as movie_gui:
         outerframe = movie_gui.parent.children[0]
         bodyframe = outerframe.children[0]
         treeview = bodyframe.children[0]
         assert treeview == TtkTreeview(
             parent=TtkFrame(parent=TtkFrame(parent=DummyTk(), padding=''),
                             padding=(10, 25, 10, 0)),
             columns=('year', 'director', 'minutes', 'notes'),
             height=25,
             selectmode='browse')
コード例 #12
0
 def test_focus_set_on_title_field(self, patch_tk, monkeypatch):
     calls = []
     monkeypatch.setattr(guiwidgets, 'focus_set',
                         lambda *args: calls.append(args))
     with self.movie_context():
         assert calls == [
             (TtkEntry(parent=TtkFrame(parent=TtkFrame(parent=DummyTk(),
                                                       padding=''),
                                       padding=(10, 25, 10, 0)),
                       textvariable=TkStringVar(),
                       width=36), )
         ]
コード例 #13
0
 def movie_context(self):
     self.neuron_linker_args = []
     all_tag_names = ('test tag 1', 'test tag 2')
     movie = guiwidgets.config.MovieUpdateDef(title='Test Movie',
                                              year=2050,
                                              director='Test Director',
                                              minutes=142,
                                              notes='Test note',
                                              tags=('test selected tag', ))
     # noinspection PyTypeChecker
     yield guiwidgets.EditMovieGUI(DummyTk(), dummy_commit_callback,
                                   dummy_delete_callback,
                                   ['commit', 'delete'], all_tag_names,
                                   movie)
コード例 #14
0
 def test_delete_calls_askyesno_dialog(self, patch_tk, monkeypatch):
     calls = []
     with self.movie_context() as movie_gui:
         monkeypatch.setattr(guiwidgets.messagebox, 'askyesno',
                             lambda **kwargs: calls.append(kwargs))
         monkeypatch.setattr(movie_gui, 'delete_callback',
                             lambda movie: None)
         monkeypatch.setattr(movie_gui, 'destroy', lambda: None)
         guiwidgets.CommonButtonbox.delete(movie_gui)
         assert calls == [
             dict(message='Do you want to delete this movie?',
                  icon='question',
                  default='no',
                  parent=DummyTk())
         ]
コード例 #15
0
 def select_movie_context(self):
     # noinspection PyTypeChecker
     yield guiwidgets.SelectMovieGUI(DummyTk(), self.fake_movie_generator(),
                                     dummy_commit_callback)
コード例 #16
0
 def test_parent_initialized(self, patch_tk):
     with self.select_movie_context() as movie_gui:
         assert movie_gui.parent == DummyTk()
         assert isinstance(movie_gui.callback, Callable)
コード例 #17
0
 def test_parent_initialized(self, patch_tk):
     with self.movie_context() as movie_gui:
         assert movie_gui.parent == DummyTk()
         assert movie_gui.all_tags == ('test tag 1', 'test tag 2')
         assert isinstance(movie_gui.callback, Callable)
コード例 #18
0
 def movie_context(self):
     global treeview_call
     treeview_call = []
     tags = ('test tag 1', 'test tag 2')
     # noinspection PyTypeChecker
     yield guiwidgets.SearchMovieGUI(DummyTk(), dummy_commit_callback, tags)