def test_adding_tags_in_the_widget(self): tw = TagsWidget() QTest.keyClicks(tw.lineEdit, 'lourd') # Called manually because we would need an event loop otherwise tw.addTag() self.assertEqual(tw.listWidget.count(), 1)
def test_remove_tag_with_delete_key(self): tw = TagsWidget() QTest.keyClicks(tw.lineEdit, 'lourd') tw.addTag() tw.listWidget.setCurrentRow(0) tw.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.NoModifier)) self.assertEqual(tw.listWidget.count(), 0)
def test_cant_add_twice_the_same(self): tw = TagsWidget() QTest.keyClicks(tw.lineEdit, 'lourd') tw.addTag() QTest.keyClicks(tw.lineEdit, 'lourd') tw.addTag() self.assertEqual(tw.listWidget.count(), 1)
def test_getting_the_entered_tags(self): tw = TagsWidget() QTest.keyClicks(tw.lineEdit, 'lourd') tw.addTag() expected = [t.id for t in Session.query(Tag.id) .filter(Tag.name == u'lourd') .all()] self.assertEqual(tw.tags(), expected)
def test_getting_the_entered_tags(self): tw = TagsWidget() QTest.keyClicks(tw.lineEdit, 'lourd') tw.addTag() expected = [ t.id for t in Session.query(Tag.id).filter(Tag.name == u'lourd').all() ] self.assertEqual(tw.tags(), expected)
def test_the_completion_popup_appears(self): tw = TagsWidget() tw.lineEdit.focusInEvent(QFocusEvent(QEvent.FocusIn)) self.assert_(tw.lineEdit.completer().popup().isVisible(), "Completion popup doesn't appear on focus")
def test_cant_add_twice_the_same_even_after_reload(self): tw = TagsWidget() QTest.keyClicks(tw.lineEdit, 'lourd') tw.addTag() Session.add(Tag(u'Another tag')) tw.reload() QTest.keyClicks(tw.lineEdit, 'lourd') tw.addTag() self.assertEqual(tw.listWidget.count(), 1)
def test_remove_tag_with_delete_key(self): tw = TagsWidget() QTest.keyClicks(tw.lineEdit, 'lourd') tw.addTag() tw.listWidget.setCurrentRow(0) tw.keyPressEvent( QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.NoModifier)) self.assertEqual(tw.listWidget.count(), 0)
def __init__(self, fro, to): super(ReEatWidget, self).__init__(Qt.Horizontal) left = QSplitter(Qt.Vertical) rw = RecipesWidget() tw = TagsWidget() tw.tagsChanged.connect(rw.reload) rw.recipeChanged.connect(tw.reload) left.addWidget(rw) left.addWidget(tw) self.addWidget(left) right = PlanningWidget(fro, to) rw.recipeRemoved.connect(right._recipe_removed) self.addWidget(right)
def test_invalid_tag_is_invalid(self): tw = TagsWidget() QTest.keyClicks(tw, 'trololo') tw.addTag() self.assertEqual(tw.listWidget.count(), 0)
def test_widget_is_empty_first(self): tw = TagsWidget() self.assertEqual(tw.listWidget.count(), 0)