Ejemplo n.º 1
0
Archivo: test.py Proyecto: cmotc/medit
 def testjunk(self):
     self.assertRaises(TypeError, item_create_instance, Item(name='wefwef'))
     item_create_instance(Item(blah='wefwef'), 'fwef')
     self.assertRaises(TypeError, item_create_instance)
     self.assertRaises(TypeError, item_create_instance, 'wefef')
     self.assertRaises(TypeError, item_create_instance, 1)
     self.assertRaises(TypeError, item_create_instance, Item, 1)
     self.assertRaises(TypeError, item_create_instance, [Item], 1)
     self.assertRaises(TypeError, item_create_instance, [Item], 'dd', name='ededed')
     self.assertRaises(TypeError, item_create_instance, [Item, {'name' : 'fff'}], 'dd', name='ededed')
Ejemplo n.º 2
0
Archivo: test.py Proyecto: cmotc/medit
 def testsave3(self):
     s = item_create_instance(Setting(default='444', data_type=str), 'id')
     self.assert_(s.save() == [])
     s.set_value('fff')
     self.assert_(s.save() == [XMLItem('id', 'fff')])
     s.set_value('')
     self.assert_(s.save() == [XMLItem('id', '')])
     s.copy()
     s = item_create_instance(Setting(default='444', data_type=str, null_ok=True), 'id')
     s.set_value(None)
     self.assert_(s.save() == [XMLItem('id', None)])
Ejemplo n.º 3
0
 def testsave3(self):
     s = item_create_instance(Setting(default='444', data_type=str), 'id')
     self.assert_(s.save() == [])
     s.set_value('fff')
     self.assert_(s.save() == [XMLItem('id', 'fff')])
     s.set_value('')
     self.assert_(s.save() == [XMLItem('id', '')])
     s.copy()
     s = item_create_instance(
         Setting(default='444', data_type=str, null_ok=True), 'id')
     s.set_value(None)
     self.assert_(s.save() == [XMLItem('id', None)])
Ejemplo n.º 4
0
Archivo: test.py Proyecto: cmotc/medit
 def testnormal(self):
     s = item_create_instance(Setting(name='name', data_type=int), '1', value=2)
     self.assert_(s.get_default() is None)
     self.assert_(not s.is_default())
     s = item_create_instance(Setting(name='name', default=8, data_type=int), '2')
     self.assert_(s.get_default() == 8)
     self.assert_(s.is_default())
     s = item_create_instance(Setting(name='name', default=8, data_type=int), '3', value=2)
     self.assert_(s.get_default() == 8)
     self.assert_(s.get_value() == 2)
     self.assert_(not s.is_default())
     s.copy()
Ejemplo n.º 5
0
Archivo: test.py Proyecto: cmotc/medit
 def testops(self):
     s1 = item_create_instance(Setting(data_type=int), 'id')
     s2 = item_create_instance(Setting(data_type=int), 'id')
     self.assert_(s1 == s2)
     s1.set_value(5)
     self.assert_(s1 != s2)
     s2.set_value(5)
     self.assert_(s1 == s2)
     s2 = s1.copy()
     self.assert_(s1 == s2)
     self.assert_(s1.equal(5))
     self.assert_(not s1.equal(s2))
     self.assert_(not s1.equal(3))
     s1.copy()
     s2.copy()
Ejemplo n.º 6
0
 def testops(self):
     s1 = item_create_instance(Setting(data_type=int), 'id')
     s2 = item_create_instance(Setting(data_type=int), 'id')
     self.assert_(s1 == s2)
     s1.set_value(5)
     self.assert_(s1 != s2)
     s2.set_value(5)
     self.assert_(s1 == s2)
     s2 = s1.copy()
     self.assert_(s1 == s2)
     self.assert_(s1.equal(5))
     self.assert_(not s1.equal(s2))
     self.assert_(not s1.equal(3))
     s1.copy()
     s2.copy()
Ejemplo n.º 7
0
Archivo: test.py Proyecto: cmotc/medit
 def testvalue2(self):
     s = item_create_instance(Setting(), 'id')
     self.assert_(s.get_default() is None)
     self.assert_(s.get_value() is None)
     s.reset()
     self.assert_(s.get_value() is None)
     s.copy()
Ejemplo n.º 8
0
 def testvalue2(self):
     s = item_create_instance(Setting(), 'id')
     self.assert_(s.get_default() is None)
     self.assert_(s.get_value() is None)
     s.reset()
     self.assert_(s.get_value() is None)
     s.copy()
Ejemplo n.º 9
0
 def testsave2(self):
     s = item_create_instance(Setting(data_type=str), 'id')
     self.assert_(s.save() == [])
     s.set_value('')
     self.assert_(s.save() == [XMLItem('id', '')])
     s.reset()
     self.assert_(s.save() == [])
     s.copy()
Ejemplo n.º 10
0
 def testload2(self):
     s = item_create_instance(Setting(data_type=int), 'id')
     node = XMLItem('id', 'fff')
     self.assertRaises(ValueError, s.load, node)
     node = XMLItem('id', '5')
     s.load(node)
     self.assert_(s.get_value() == 5)
     s.copy()
Ejemplo n.º 11
0
Archivo: test.py Proyecto: cmotc/medit
 def testload2(self):
     s = item_create_instance(Setting(data_type=int), 'id')
     node = XMLItem('id', 'fff')
     self.assertRaises(ValueError, s.load, node)
     node = XMLItem('id', '5')
     s.load(node)
     self.assert_(s.get_value() == 5)
     s.copy()
Ejemplo n.º 12
0
Archivo: test.py Proyecto: cmotc/medit
 def testsave2(self):
     s = item_create_instance(Setting(data_type=str), 'id')
     self.assert_(s.save() == [])
     s.set_value('')
     self.assert_(s.save() == [XMLItem('id', '')])
     s.reset()
     self.assert_(s.save() == [])
     s.copy()
Ejemplo n.º 13
0
 def testnormal(self):
     s = item_create_instance(Setting(name='name', data_type=int),
                              '1',
                              value=2)
     self.assert_(s.get_default() is None)
     self.assert_(not s.is_default())
     s = item_create_instance(
         Setting(name='name', default=8, data_type=int), '2')
     self.assert_(s.get_default() == 8)
     self.assert_(s.is_default())
     s = item_create_instance(Setting(name='name', default=8,
                                      data_type=int),
                              '3',
                              value=2)
     self.assert_(s.get_default() == 8)
     self.assert_(s.get_value() == 2)
     self.assert_(not s.is_default())
     s.copy()
Ejemplo n.º 14
0
 def testload(self):
     s = item_create_instance(Setting(data_type=str), 'id')
     node = XMLItem('id', 'fff')
     s.load(node)
     self.assert_(s.get_value() == 'fff')
     node = XMLItem('id', None)
     s.load(node)
     self.assert_(s.get_value() is None)
     s.copy()
Ejemplo n.º 15
0
 def testjunk(self):
     self.assertRaises(TypeError, item_create_instance, Item(name='wefwef'))
     item_create_instance(Item(blah='wefwef'), 'fwef')
     self.assertRaises(TypeError, item_create_instance)
     self.assertRaises(TypeError, item_create_instance, 'wefef')
     self.assertRaises(TypeError, item_create_instance, 1)
     self.assertRaises(TypeError, item_create_instance, Item, 1)
     self.assertRaises(TypeError, item_create_instance, [Item], 1)
     self.assertRaises(TypeError,
                       item_create_instance, [Item],
                       'dd',
                       name='ededed')
     self.assertRaises(TypeError,
                       item_create_instance, [Item, {
                           'name': 'fff'
                       }],
                       'dd',
                       name='ededed')
Ejemplo n.º 16
0
Archivo: test.py Proyecto: cmotc/medit
 def testload(self):
     s = item_create_instance(Setting(data_type=str), 'id')
     node = XMLItem('id', 'fff')
     s.load(node)
     self.assert_(s.get_value() == 'fff')
     node = XMLItem('id', None)
     s.load(node)
     self.assert_(s.get_value() is None)
     s.copy()
Ejemplo n.º 17
0
Archivo: test.py Proyecto: cmotc/medit
 def testdatatype(self):
     s = item_create_instance(Setting(data_type=str), 'id')
     self.assert_(s.get_default() is None)
     self.assert_(s.get_value() is None)
     self.assertRaises(TypeError, s.set_value, 8)
     s.reset()
     self.assert_(s.get_value() is None)
     s.set_string('5')
     self.assert_(s.get_value() == '5')
     s.copy()
Ejemplo n.º 18
0
Archivo: test.py Proyecto: cmotc/medit
 def testdict2(self):
     S = Setting(data_type=int, default=5)
     s = item_create_instance(Dict(S), 'id')
     self.assert_(s == s.copy())
     s['blah'] = S.create_instance('dd')
     self.assert_(s['blah'] == 5)
     self.assertRaises(Exception, self.assign, s, 'fff', 5)
     self.assertRaises(Exception, self.assign, s, 'fff', '44')
     self.assertRaises(Exception, self.assign, s, 'fff', None)
     self.assert_(s == s.copy())
Ejemplo n.º 19
0
 def testdatatype(self):
     s = item_create_instance(Setting(data_type=str), 'id')
     self.assert_(s.get_default() is None)
     self.assert_(s.get_value() is None)
     self.assertRaises(TypeError, s.set_value, 8)
     s.reset()
     self.assert_(s.get_value() is None)
     s.set_string('5')
     self.assert_(s.get_value() == '5')
     s.copy()
Ejemplo n.º 20
0
 def testdict2(self):
     S = Setting(data_type=int, default=5)
     s = item_create_instance(Dict(S), 'id')
     self.assert_(s == s.copy())
     s['blah'] = S.create_instance('dd')
     self.assert_(s['blah'] == 5)
     self.assertRaises(Exception, self.assign, s, 'fff', 5)
     self.assertRaises(Exception, self.assign, s, 'fff', '44')
     self.assertRaises(Exception, self.assign, s, 'fff', None)
     self.assert_(s == s.copy())
Ejemplo n.º 21
0
Archivo: test.py Proyecto: cmotc/medit
 def testdict(self):
     s = item_create_instance(Dict(str), 'id')
     self.assert_(s == s.copy())
     s['blah'] = 'fwef'
     self.assert_(s['blah'] == 'fwef')
     s['foo'] = 'ddd'
     self.assert_(s['foo'] == 'ddd')
     s['foo'] = 'blah'
     self.assert_(s['foo'] == 'blah')
     self.assert_(s == s.copy())
     self.assertRaises(Exception, self.assign, s, 'fff', 3)
Ejemplo n.º 22
0
 def testdict(self):
     s = item_create_instance(Dict(str), 'id')
     self.assert_(s == s.copy())
     s['blah'] = 'fwef'
     self.assert_(s['blah'] == 'fwef')
     s['foo'] = 'ddd'
     self.assert_(s['foo'] == 'ddd')
     s['foo'] = 'blah'
     self.assert_(s['foo'] == 'blah')
     self.assert_(s == s.copy())
     self.assertRaises(Exception, self.assign, s, 'fff', 3)
Ejemplo n.º 23
0
 def testnormal(self):
     item_create_instance(Item(name='wefwef'), 'id')
     item_create_instance(Item(name='wefwef', description='ewfwef'), 'id')
     item_create_instance(Item, 'id')
     self.assertRaises(TypeError, item_create_instance,
                       [Item, {
                           'name': 'ffff'
                       }], 'id')
Ejemplo n.º 24
0
 def testdatatype2(self):
     s = item_create_instance(Setting(data_type=int), 'id')
     self.assert_(s.get_default() is None)
     self.assert_(s.get_value() is None)
     s.set_value(8)
     self.assert_(s.get_value() == 8)
     self.assertRaises(TypeError, s.set_value, '8')
     s.reset()
     self.assert_(s.get_value() is None)
     s.set_string('5')
     self.assert_(s.get_value() == 5)
     self.assertRaises(Exception, s.set_string, 'ewfwef')
     self.assertRaises(TypeError, s.set_value, 'ewfwef')
     s.copy()
Ejemplo n.º 25
0
Archivo: test.py Proyecto: cmotc/medit
 def testdatatype2(self):
     s = item_create_instance(Setting(data_type=int), 'id')
     self.assert_(s.get_default() is None)
     self.assert_(s.get_value() is None)
     s.set_value(8)
     self.assert_(s.get_value() == 8)
     self.assertRaises(TypeError, s.set_value, '8')
     s.reset()
     self.assert_(s.get_value() is None)
     s.set_string('5')
     self.assert_(s.get_value() == 5)
     self.assertRaises(Exception, s.set_string, 'ewfwef')
     self.assertRaises(TypeError, s.set_value, 'ewfwef')
     s.copy()
Ejemplo n.º 26
0
Archivo: test.py Proyecto: cmotc/medit
 def testnormal(self):
     item_create_instance(Item(name='wefwef'), 'id')
     item_create_instance(Item(name='wefwef', description='ewfwef'), 'id')
     item_create_instance(Item, 'id')
     self.assertRaises(TypeError, item_create_instance, [Item, {'name' : 'ffff'}], 'id')