Ejemplo n.º 1
0
    def test_data(self):
        """data returns proper text to display"""
        model = ConcordanceModel()
        model.set_width(2)
        self.assertEqual(model.rowCount(QModelIndex()), 0)

        model.set_corpus(self.corpus)
        model.set_word("of", DummyState)

        # The same document in two rows
        self.assertEqual(model.rowCount(QModelIndex()), 7)
        self.assertEqual(model.data(model.index(0, 0)), "A survey")
        self.assertEqual(model.data(model.index(0, 1)), "of")
        self.assertEqual(model.data(model.index(0, 2)), "user opinion")

        self.assertEqual(model.data(model.index(1, 0)), "user opinion")
        self.assertEqual(model.data(model.index(1, 1)), "of")
        self.assertEqual(model.data(model.index(1, 2)), "computer system")

        # The third column has just a single word
        self.assertEqual(model.data(model.index(2, 0)), "engineering testing")
        self.assertEqual(model.data(model.index(2, 1)), "of")
        self.assertEqual(model.data(model.index(2, 2)), "EPS")

        # The first column has just a single word
        self.assertEqual(model.data(model.index(3, 0)), "Relation")
        self.assertEqual(model.data(model.index(3, 1)), "of")
        self.assertEqual(model.data(model.index(3, 2)), "user perceived")
Ejemplo n.º 2
0
    def test_data(self):
        """data returns proper text to display"""
        model = ConcordanceModel()
        model.set_width(2)
        self.assertEqual(model.rowCount(QModelIndex()), 0)

        model.set_corpus(self.corpus)
        model.set_word("of")

        # The same document in two rows
        self.assertEqual(model.rowCount(QModelIndex()), 7)
        self.assertEqual(model.data(model.index(0, 0)), "A survey")
        self.assertEqual(model.data(model.index(0, 1)), "of")
        self.assertEqual(model.data(model.index(0, 2)), "user opinion")

        self.assertEqual(model.data(model.index(1, 0)), "user opinion")
        self.assertEqual(model.data(model.index(1, 1)), "of")
        self.assertEqual(model.data(model.index(1, 2)), "computer system")

        # The third column has just a single word
        self.assertEqual(model.data(model.index(2, 0)), "engineering testing")
        self.assertEqual(model.data(model.index(2, 1)), "of")
        self.assertEqual(model.data(model.index(2, 2)), "EPS")

        # The first column has just a single word
        self.assertEqual(model.data(model.index(3, 0)), "Relation")
        self.assertEqual(model.data(model.index(3, 1)), "of")
        self.assertEqual(model.data(model.index(3, 2)), "user perceived")
Ejemplo n.º 3
0
    def test_color_proper_rows(self):
        """Rows are colored corresponding to the document"""
        model = ConcordanceModel()
        model.set_width(2)
        model.set_corpus(self.corpus)
        model.set_word("of", DummyState)

        color1 = model.data(model.index(0, 0), Qt.BackgroundRole)
        self.assertEqual(model.data(model.index(1, 0), Qt.BackgroundRole),
                         color1)
        self.assertNotEqual(model.data(model.index(2, 0), Qt.BackgroundRole),
                            color1)
Ejemplo n.º 4
0
    def test_color_proper_rows(self):
        """Rows are colored corresponding to the document"""
        model = ConcordanceModel()
        model.set_width(2)
        model.set_corpus(self.corpus)
        model.set_word("of")

        color1 = model.data(model.index(0, 0), Qt.BackgroundRole)
        self.assertEqual(model.data(model.index(1, 0), Qt.BackgroundRole),
                         color1)
        self.assertNotEqual(model.data(model.index(2, 0), Qt.BackgroundRole),
                            color1)
Ejemplo n.º 5
0
    def test_set_word(self):
        """Concondance.set_word resets the indices"""
        # Human machine interface for lab abc computer applications
        model = ConcordanceModel()
        model.set_corpus(self.corpus)
        model.set_width(2)

        model.set_word("of", DummyState)
        self.assertEqual(model.rowCount(QModelIndex()), 7)
        self.assertEqual(model.data(model.index(0, 0)), "A survey")

        model.set_word("lab", DummyState)
        self.assertEqual(model.rowCount(QModelIndex()), 1)
        self.assertEqual(model.data(model.index(0, 0)), "interface for")

        model.set_word(None, DummyState)
        self.assertEqual(model.rowCount(QModelIndex()), 0)
Ejemplo n.º 6
0
    def test_set_word(self):
        """Concondance.set_word resets the indices"""
        # Human machine interface for lab abc computer applications
        model = ConcordanceModel()
        model.set_corpus(self.corpus)
        model.set_width(2)

        model.set_word("of")
        self.assertEqual(model.rowCount(QModelIndex()), 7)
        self.assertEqual(model.data(model.index(0, 0)), "A survey")

        model.set_word("lab")
        self.assertEqual(model.rowCount(QModelIndex()), 1)
        self.assertEqual(model.data(model.index(0, 0)), "interface for")

        model.set_word(None)
        self.assertEqual(model.rowCount(QModelIndex()), 0)
Ejemplo n.º 7
0
 def test_order_doesnt_matter(self):
     """Setting the word or the corpus first works"""
     model = ConcordanceModel()
     model.set_width(2)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_corpus(self.corpus)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_word("of", DummyState)
     self.assertEqual(model.rowCount(QModelIndex()), 7)
     model.set_word("", DummyState)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_word(None, DummyState)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_corpus(None)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_word("of", DummyState)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_corpus(self.corpus)
     self.assertEqual(model.rowCount(QModelIndex()), 7)
     model.set_corpus(None)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_corpus(None)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
Ejemplo n.º 8
0
 def test_order_doesnt_matter(self):
     """Setting the word or the corpus first works"""
     model = ConcordanceModel()
     model.set_width(2)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_corpus(self.corpus)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_word("of")
     self.assertEqual(model.rowCount(QModelIndex()), 7)
     model.set_word("")
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_word(None)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_corpus(None)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_word("of")
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_corpus(self.corpus)
     self.assertEqual(model.rowCount(QModelIndex()), 7)
     model.set_corpus(None)
     self.assertEqual(model.rowCount(QModelIndex()), 0)
     model.set_corpus(None)
     self.assertEqual(model.rowCount(QModelIndex()), 0)