Beispiel #1
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')
Beispiel #2
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)])
Beispiel #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)])
Beispiel #4
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()
Beispiel #5
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()
Beispiel #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()
Beispiel #7
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()
Beispiel #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()
Beispiel #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()
Beispiel #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()
Beispiel #11
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()
Beispiel #12
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()
Beispiel #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()
Beispiel #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()
Beispiel #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')
Beispiel #16
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()
Beispiel #17
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()
Beispiel #18
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())
Beispiel #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()
Beispiel #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())
Beispiel #21
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)
Beispiel #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)
Beispiel #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')
Beispiel #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()
Beispiel #25
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()
Beispiel #26
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')