Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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")
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
    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)
Exemplo n.º 11
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)
Exemplo n.º 12
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)
Exemplo n.º 13
0
    def test_invalid_tag_is_invalid(self):
        tw = TagsWidget()
        QTest.keyClicks(tw, 'trololo')
        tw.addTag()

        self.assertEqual(tw.listWidget.count(), 0)
Exemplo n.º 14
0
    def test_invalid_tag_is_invalid(self):
        tw = TagsWidget()
        QTest.keyClicks(tw, 'trololo')
        tw.addTag()

        self.assertEqual(tw.listWidget.count(), 0)
Exemplo n.º 15
0
    def test_widget_is_empty_first(self):
        tw = TagsWidget()

        self.assertEqual(tw.listWidget.count(), 0)