import test_translate
import test_uninstall
import test_view_validation
-import test_convert
# This need a change in `oe run-tests` to only run fast_suite + checks by default.
# import test_xmlrpc
test_misc,
test_osv,
test_translate,
- test_convert,
]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
+# -*- coding: utf-8 -*-
+from . import test_convert
+
+checks = [
+ test_convert
+]
--- /dev/null
+import collections
+import unittest2
+from lxml import etree as ET
+from lxml.builder import E
+
+from openerp.tests import common
+
+from openerp.tools.convert import _eval_xml
+
+Field = E.field
+Value = E.value
+class TestEvalXML(common.TransactionCase):
+ def eval_xml(self, node, obj=None, idref=None):
+ return _eval_xml(obj, node, pool=None, cr=self.cr, uid=self.uid,
+ idref=idref, context=None)
+
+ def test_char(self):
+ self.assertEqual(
+ self.eval_xml(Field("foo")),
+ "foo")
+ self.assertEqual(
+ self.eval_xml(Field("None")),
+ "None")
+
+ def test_int(self):
+ self.assertIsNone(
+ self.eval_xml(Field("None", type='int')),
+ "what the fuck?")
+ self.assertEqual(
+ self.eval_xml(Field(" 42 ", type="int")),
+ 42)
+
+ with self.assertRaises(ValueError):
+ self.eval_xml(Field("4.82", type="int"))
+
+ with self.assertRaises(ValueError):
+ self.eval_xml(Field("Whelp", type="int"))
+
+ def test_float(self):
+ self.assertEqual(
+ self.eval_xml(Field("4.78", type="float")),
+ 4.78)
+
+ with self.assertRaises(ValueError):
+ self.eval_xml(Field("None", type="float"))
+
+ with self.assertRaises(ValueError):
+ self.eval_xml(Field("Foo", type="float"))
+
+ def test_list(self):
+ self.assertEqual(
+ self.eval_xml(Field(type="list")),
+ [])
+
+ self.assertEqual(
+ self.eval_xml(Field(
+ Value("foo"),
+ Value("5", type="int"),
+ Value("4.76", type="float"),
+ Value("None", type="int"),
+ type="list"
+ )),
+ ["foo", 5, 4.76, None])
+
+ def test_file(self):
+ Obj = collections.namedtuple('Obj', 'module')
+ obj = Obj('test_convert')
+ self.assertEqual(
+ self.eval_xml(Field('test_file.txt', type='file'), obj),
+ 'test_convert,test_file.txt')
+
+ with self.assertRaises(IOError):
+ self.eval_xml(Field('test_nofile.txt', type='file'), obj)
+
+ @unittest2.skip("not tested")
+ def test_xml(self):
+ pass
+
+ @unittest2.skip("not tested")
+ def test_html(self):
+ pass
+
+
+++ /dev/null
-import collections
-import unittest2
-from lxml import etree as ET
-from lxml.builder import E
-
-from . import common
-
-from openerp.tools.convert import _eval_xml
-
-Field = E.field
-Value = E.value
-class TestEvalXML(common.TransactionCase):
- def eval_xml(self, node, obj=None, idref=None):
- return _eval_xml(obj, node, pool=None, cr=self.cr, uid=self.uid,
- idref=idref, context=None)
-
- def test_char(self):
- self.assertEqual(
- self.eval_xml(Field("foo")),
- "foo")
- self.assertEqual(
- self.eval_xml(Field("None")),
- "None")
-
- def test_int(self):
- self.assertIsNone(
- self.eval_xml(Field("None", type='int')),
- "what the fuck?")
- self.assertEqual(
- self.eval_xml(Field(" 42 ", type="int")),
- 42)
-
- with self.assertRaises(ValueError):
- self.eval_xml(Field("4.82", type="int"))
-
- with self.assertRaises(ValueError):
- self.eval_xml(Field("Whelp", type="int"))
-
- def test_float(self):
- self.assertEqual(
- self.eval_xml(Field("4.78", type="float")),
- 4.78)
-
- with self.assertRaises(ValueError):
- self.eval_xml(Field("None", type="float"))
-
- with self.assertRaises(ValueError):
- self.eval_xml(Field("Foo", type="float"))
-
- def test_list(self):
- self.assertEqual(
- self.eval_xml(Field(type="list")),
- [])
-
- self.assertEqual(
- self.eval_xml(Field(
- Value("foo"),
- Value("5", type="int"),
- Value("4.76", type="float"),
- Value("None", type="int"),
- type="list"
- )),
- ["foo", 5, 4.76, None])
-
- def test_file(self):
- Obj = collections.namedtuple('Obj', 'module')
- obj = Obj('test_convert')
- self.assertEqual(
- self.eval_xml(Field('test_file.txt', type='file'), obj),
- 'test_convert,test_file.txt')
-
- with self.assertRaises(IOError):
- self.eval_xml(Field('test_nofile.txt', type='file'), obj)
-
- @unittest2.skip("not tested")
- def test_xml(self):
- pass
-
- @unittest2.skip("not tested")
- def test_html(self):
- pass
-
-
from ..modules import module
path = node.text.strip()
if not module.get_module_resource(self.module, path):
- raise IOError("No such file or directory: '%s'" % path)
+ raise IOError("No such file or directory: '%s' in %s" % (
+ path, self.module))
return '%s,%s' % (self.module, path)
if t in ('char', 'int', 'float'):
d = node.text