Exemplo n.º 1
0
    def test_sqla_table_traverse(self):
        from ptah.manage.sqla import SQLAModule, Record
        from ptah.settings import Session, SettingRecord

        inst = SettingRecord(name='test', value='12345')
        Session.add(inst)
        Session.flush()

        mod = SQLAModule(None, DummyRequest())
        table = mod['psqla-ptah_settings']

        rec = table[str(inst.name)]

        self.assertIsInstance(rec, Record)
        self.assertEqual(rec.pname, 'name')
        self.assertIsNotNone(rec.pcolumn)
        self.assertIsNotNone(rec.data)

        self.assertRaises(KeyError, table.__getitem__, 'add.html')
        self.assertRaises(KeyError, table.__getitem__, 'unknown')
Exemplo n.º 2
0
    def test_sqla_table_traverse(self):
        from ptah.manage.sqla import SQLAModule, Record
        from ptah.settings import Session, SettingRecord

        inst = SettingRecord(name='test', value='12345')
        Session.add(inst)
        Session.flush()

        mod = SQLAModule(None, DummyRequest())
        table = mod['psqla-ptah_settings']

        rec = table[str(inst.name)]

        self.assertIsInstance(rec, Record)
        self.assertEqual(rec.pname, 'name')
        self.assertIsNotNone(rec.pcolumn)
        self.assertIsNotNone(rec.data)

        self.assertRaises(KeyError, table.__getitem__, 'add.html')
        self.assertRaises(KeyError, table.__getitem__, 'unknown')
Exemplo n.º 3
0
    def test_settings_updatedb_set_default(self):
        grp = self._make_grp()
        grp.updatedb(node1 = 'new text', node2 = 65)
        grp.updatedb(node1 = 'new text 2', node2 = 50)

        from ptah.settings import Session, SettingRecord

        res = {}
        for rec in Session.query(SettingRecord):
            res[rec.name] = rec.value

        self.assertEqual(len(res), 1)
        self.assertIn('group.node1', res)
        self.assertEqual(res['group.node1'], '"new text 2"')
Exemplo n.º 4
0
    def test_settings_updatedb_unknown(self):
        grp = self._make_grp()
        grp.updatedb(node1 = 'new text',
                     node2 = 65,
                     node3 = 500)

        self.assertEqual(grp['node3'], 500)

        from ptah.settings import Session, SettingRecord

        res = {}
        for rec in Session.query(SettingRecord):
            res[rec.name] = rec.value

        self.assertEqual(len(res), 2)
        self.assertNotIn('group.node3', res)
Exemplo n.º 5
0
    def test_settings_updatedb(self):
        grp = self._make_grp()
        grp.updatedb(node1 = 'new text',
                     node2 = 65)

        self.assertEqual(grp['node1'], 'new text')
        self.assertEqual(grp['node2'], 65)

        from ptah.settings import Session, SettingRecord

        res = {}
        for rec in Session.query(SettingRecord):
            res[rec.name] = rec.value

        self.assertIn('group.node1', res)
        self.assertIn('group.node2', res)
        self.assertEqual(res['group.node1'], '"new text"')
        self.assertEqual(res['group.node2'], '65')