示例#1
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)
示例#2
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)
示例#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)
示例#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)
示例#5
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)
示例#6
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)
示例#7
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)
示例#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)
示例#9
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)
示例#10
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)
示例#11
0
    def test_invalid_tag_is_invalid(self):
        tw = TagsWidget()
        QTest.keyClicks(tw, 'trololo')
        tw.addTag()

        self.assertEqual(tw.listWidget.count(), 0)
示例#12
0
    def test_invalid_tag_is_invalid(self):
        tw = TagsWidget()
        QTest.keyClicks(tw, 'trololo')
        tw.addTag()

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