class TestTransformationModule(WidgetTest):
    def setUp(self):
        self.editor = TransformationModule()

    @property
    def check_boxes(self):
        return [cb for i, cb in self.editor._MultipleMethodModule__cbs]

    def test_init(self):
        check_boxes = self.check_boxes
        self.assertTrue(check_boxes[0].isChecked())
        self.assertGreater(len(check_boxes[0].toolTip()), 0)
        for i in range(1, len(check_boxes)):
            self.assertFalse(check_boxes[i].isChecked())
            self.assertGreater(len(check_boxes[i].toolTip()), 0)

    def test_parameters(self):
        params = {"methods": [TransformationModule.Lowercase]}
        self.assertDictEqual(self.editor.parameters(), params)

    def test_set_parameters(self):
        params = {
            "methods":
            [TransformationModule.Accents, TransformationModule.Parse]
        }
        self.editor.setParameters(params)
        self.assertDictEqual(self.editor.parameters(), params)

        check_boxes = self.check_boxes
        self.assertFalse(check_boxes[0].isChecked())
        self.assertTrue(check_boxes[1].isChecked())
        self.assertTrue(check_boxes[2].isChecked())
        self.assertFalse(check_boxes[3].isChecked())

    def test_createinstance(self):
        pp = self.editor.createinstance(self.editor.parameters())
        self.assertIsInstance(pp[0], LowercaseTransformer)

        params = {
            "methods":
            [TransformationModule.Lowercase, TransformationModule.Parse]
        }
        pp = self.editor.createinstance(params)
        self.assertIsInstance(pp[0], LowercaseTransformer)
        self.assertIsInstance(pp[1], HtmlTransformer)

    def test_repr(self):
        self.assertEqual(str(self.editor), "Lowercase")
        params = {
            "methods":
            [TransformationModule.Lowercase, TransformationModule.Parse]
        }
        self.editor.setParameters(params)
        self.assertEqual(str(self.editor), "Lowercase, Parse html")
 def setUp(self):
     self.editor = TransformationModule()