class TestPOSTaggerModule(WidgetTest):
    def setUp(self):
        self.editor = POSTaggingModule()

    @property
    def buttons(self):
        return self.editor._SingleMethodModule__group.buttons()

    def test_init(self):
        self.assertTrue(self.buttons[0].isChecked())
        for i in range(1, 2):
            self.assertFalse(self.buttons[i].isChecked())

    def test_parameters(self):
        params = {"method": POSTaggingModule.Averaged}
        self.assertDictEqual(self.editor.parameters(), params)

    def test_set_parameters(self):
        params = {"method": POSTaggingModule.MaxEnt}
        self.editor.setParameters(params)
        self.assertDictEqual(self.editor.parameters(), params)

        self.assertTrue(self.buttons[1].isChecked())
        for i in range(1):
            self.assertFalse(self.buttons[i].isChecked())

    def test_createinstance(self):
        pp = self.editor.createinstance(self.editor.parameters())
        self.assertIsInstance(pp, AveragedPerceptronTagger)

        pp = self.editor.createinstance({"method": POSTaggingModule.MaxEnt})
        self.assertIsInstance(pp, MaxEntTagger)

        # TODO - implement StanfordPOSTagger
        # pp = self.editor.createinstance({"method": POSTaggingModule.Stanford})
        # self.assertIsInstance(pp, StanfordPOSTagger)

    def test_repr(self):
        self.assertEqual(str(self.editor), "Averaged Perceptron Tagger")
 def setUp(self):
     self.editor = POSTaggingModule()