コード例 #1
0
class SnippetsVarDialogTest(unittest.TestCase, BaseOutWikerGUIMixin):
    def setUp(self):
        self.initApplication()
        mainWnd = self.application.mainWindow
        plugins_dir = ["plugins/snippets"]

        self.loader = PluginsLoader(self.application)
        self.loader.load(plugins_dir)

        from snippets.gui.variablesdialog import VariablesDialog
        self._dialog = VariablesDialog(mainWnd)

    def tearDown(self):
        self._dialog.Destroy()
        self.loader.clear()
        self.destroyApplication()

    def test_empty(self):
        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {})

    def test_single_empty(self):
        self._dialog.addStringVariable('test')
        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {'test': ''})

    def test_single(self):
        self._dialog.addStringVariable('test')
        self._dialog.setStringVariable('test', 'Проверка')

        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {'test': 'Проверка'})

    def test_two_items(self):
        self._dialog.addStringVariable('test_1')
        self._dialog.addStringVariable('test_2')

        self._dialog.setStringVariable('test_1', 'Проверка_1')
        self._dialog.setStringVariable('test_2', 'Проверка_2')

        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {'test_1': 'Проверка_1',
                                     'test_2': 'Проверка_2'})

    def test_no_item(self):
        self.assertRaises(KeyError,
                          self._dialog.setStringVariable,
                          'test',
                          'test')
コード例 #2
0
class SnippetsVarDialogTest(BaseMainWndTest):
    def setUp(self):
        BaseMainWndTest.setUp(self)
        mainWnd = Application.mainWindow
        plugins_dir = [u"../plugins/snippets"]

        self.loader = PluginsLoader(Application)
        self.loader.load(plugins_dir)

        from snippets.gui.variablesdialog import VariablesDialog
        self._dialog = VariablesDialog(mainWnd)

    def tearDown(self):
        self._dialog.Destroy()
        self.loader.clear()
        BaseMainWndTest.tearDown(self)

    def test_empty(self):
        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {})

    def test_single_empty(self):
        self._dialog.addStringVariable(u'test')
        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {u'test': u''})

    def test_single(self):
        self._dialog.addStringVariable(u'test')
        self._dialog.setStringVariable(u'test', u'Проверка')

        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {u'test': u'Проверка'})

    def test_two_items(self):
        self._dialog.addStringVariable(u'test_1')
        self._dialog.addStringVariable(u'test_2')

        self._dialog.setStringVariable(u'test_1', u'Проверка_1')
        self._dialog.setStringVariable(u'test_2', u'Проверка_2')

        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {
            u'test_1': u'Проверка_1',
            u'test_2': u'Проверка_2'
        })

    def test_no_item(self):
        self.assertRaises(KeyError, self._dialog.setStringVariable, u'test',
                          u'test')
コード例 #3
0
class SnippetsVarDialogTest(BaseMainWndTest):
    def setUp(self):
        BaseMainWndTest.setUp(self)
        mainWnd = Application.mainWindow
        plugins_dir = [u"../plugins/snippets"]

        self.loader = PluginsLoader(Application)
        self.loader.load(plugins_dir)

        from snippets.gui.variablesdialog import VariablesDialog
        self._dialog = VariablesDialog(mainWnd)

    def tearDown(self):
        self._dialog.Destroy()
        self.loader.clear()
        BaseMainWndTest.tearDown(self)

    def test_empty(self):
        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {})

    def test_single_empty(self):
        self._dialog.addStringVariable(u'test')
        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {u'test': u''})

    def test_single(self):
        self._dialog.addStringVariable(u'test')
        self._dialog.setStringVariable(u'test', u'Проверка')

        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {u'test': u'Проверка'})

    def test_two_items(self):
        self._dialog.addStringVariable(u'test_1')
        self._dialog.addStringVariable(u'test_2')

        self._dialog.setStringVariable(u'test_1', u'Проверка_1')
        self._dialog.setStringVariable(u'test_2', u'Проверка_2')

        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {u'test_1': u'Проверка_1',
                                     u'test_2': u'Проверка_2'})

    def test_no_item(self):
        self.assertRaises(KeyError,
                          self._dialog.setStringVariable,
                          u'test',
                          u'test')
コード例 #4
0
ファイル: test_vardialog.py プロジェクト: Jenyay/outwiker
class SnippetsVarDialogTest(unittest.TestCase, BaseOutWikerGUIMixin):
    def setUp(self):
        self.initApplication()
        mainWnd = self.application.mainWindow
        plugins_dir = ["../plugins/snippets"]

        self.loader = PluginsLoader(self.application)
        self.loader.load(plugins_dir)

        from snippets.gui.variablesdialog import VariablesDialog
        self._dialog = VariablesDialog(mainWnd)

    def tearDown(self):
        self._dialog.Destroy()
        self.loader.clear()
        self.destroyApplication()

    def test_empty(self):
        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {})

    def test_single_empty(self):
        self._dialog.addStringVariable('test')
        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {'test': ''})

    def test_single(self):
        self._dialog.addStringVariable('test')
        self._dialog.setStringVariable('test', 'Проверка')

        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {'test': 'Проверка'})

    def test_two_items(self):
        self._dialog.addStringVariable('test_1')
        self._dialog.addStringVariable('test_2')

        self._dialog.setStringVariable('test_1', 'Проверка_1')
        self._dialog.setStringVariable('test_2', 'Проверка_2')

        variables = self._dialog.getVarDict()
        self.assertEqual(variables, {'test_1': 'Проверка_1',
                                     'test_2': 'Проверка_2'})

    def test_no_item(self):
        self.assertRaises(KeyError,
                          self._dialog.setStringVariable,
                          'test',
                          'test')