class TestNgramsModule(WidgetTest):
    def setUp(self):
        self.editor = NgramsModule()

    @property
    def spins(self):
        range = self.editor._NgramsModule__range_spins
        return range._spin_start, range._spin_end

    def test_init(self):
        self.assertEqual(self.spins[0].value(), 1)
        self.assertEqual(self.spins[1].value(), 2)

    def test_parameters(self):
        params = {"start": 1, "end": 2}
        self.assertDictEqual(self.editor.parameters(), params)

    def test_set_parameters(self):
        self.editor.setParameters({"start": 3, "end": 7})
        self.assertDictEqual(self.editor.parameters(), {"start": 3, "end": 7})

        self.assertEqual(self.spins[0].value(), 3)
        self.assertEqual(self.spins[1].value(), 7)

    def test_createinstance(self):
        pp = self.editor.createinstance(self.editor.parameters())
        self.assertIsInstance(pp, NGrams)
        self.assertEqual(pp._NGrams__range, (1, 2))

        params = {"start": 4}
        pp = self.editor.createinstance(params)
        self.assertIsInstance(pp, NGrams)
        self.assertEqual(pp._NGrams__range, (4, 2))

    def test_repr(self):
        self.assertEqual(str(self.editor), "(1, 2)")
 def setUp(self):
     self.editor = NgramsModule()