return isinstance(node, types.StringTypes)
def is_assert(node):
- return _is_yaml_mapping(node, yaml_tag.Assert)
+ return isinstance(node, yaml_tag.Assert) \
+ or _is_yaml_mapping(node, yaml_tag.Assert)
def is_record(node):
return _is_yaml_mapping(node, yaml_tag.Record)
def is_eval(node):
return isinstance(node, yaml_tag.Eval)
-
+
def is_ref(node):
return isinstance(node, yaml_tag.Ref) \
or _is_yaml_mapping(node, yaml_tag.Ref)
-
+
def is_ir_set(node):
return _is_yaml_mapping(node, yaml_tag.IrSet)
+def is_string(node):
+ return isinstance(node, basestring)
class TestReport(object):
def __init__(self):
else:
module = self.module
checked_xml_id = xml_id
- ir_id = self.pool.get('ir.model.data')._get_id(self.cr, self.uid, module, checked_xml_id)
- obj = self.pool.get('ir.model.data').read(self.cr, self.uid, ir_id, ['res_id'])
- id = int(obj['res_id'])
+ _, id = self.pool.get('ir.model.data').get_object_reference(self.cr, self.uid, module, checked_xml_id)
self.id_map[xml_id] = id
return id
elif assertion.search:
q = eval(assertion.search, self.eval_context)
ids = self.pool.get(assertion.model).search(self.cr, self.uid, q, context=assertion.context)
- if not ids:
+ else:
raise YamlImportException('Nothing to assert: you must give either an id or a search criteria.')
return ids
def process_assert(self, node):
- assertion, expressions = node.items()[0]
+ if isinstance(node, dict):
+ assertion, expressions = node.items()[0]
+ else:
+ assertion, expressions = node, []
if self.isnoupdate(assertion) and self.mode != 'init':
self.logger.warn('This assertion was not evaluated ("%s").' % assertion.string)
return
model = self.get_model(assertion.model)
ids = self._get_assertion_id(assertion)
- if assertion.count and len(ids) != assertion.count:
+ if assertion.count is not None and len(ids) != assertion.count:
msg = 'assertion "%s" failed!\n' \
' Incorrect search count:\n' \
' expected count: %d\n' \
else:
self.validate_xml_id(record.id)
if self.isnoupdate(record) and self.mode != 'init':
- id = self.pool.get('ir.model.data')._update_dummy(self.cr, self.uid, record.model, self.module, record.id)
+ id = self.pool.get('ir.model.data')._update_dummy(self.cr, 1, record.model, self.module, record.id)
# check if the resource already existed at the last update
if id:
self.id_map[record] = int(id)
self.logger.debug("RECORD_DICT %s" % record_dict)
#context = self.get_context(record, self.eval_context)
context = record.context #TOFIX: record.context like {'withoutemployee':True} should pass from self.eval_context. example: test_project.yml in project module
- id = self.pool.get('ir.model.data')._update(self.cr, self.uid, record.model, \
+ id = self.pool.get('ir.model.data')._update(self.cr, 1, record.model, \
self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode, context=context)
self.id_map[record.id] = int(id)
if config.get('import_partial'):
elif column._type == "many2many":
ids = [self.get_id(xml_id) for xml_id in expression]
value = [(6, 0, ids)]
+ elif column._type == "date" and is_string(expression):
+ # enforce ISO format for string date values, to be locale-agnostic during tests
+ time.strptime(expression, misc.DEFAULT_SERVER_DATE_FORMAT)
+ value = expression
+ elif column._type == "datetime" and is_string(expression):
+ # enforce ISO format for string datetime values, to be locale-agnostic during tests
+ time.strptime(expression, misc.DEFAULT_SERVER_DATETIME_FORMAT)
+ value = expression
else: # scalar field
if is_eval(expression):
value = self.process_eval(expression)
self._set_group_values(node, values)
- pid = self.pool.get('ir.model.data')._update(self.cr, self.uid, \
+ pid = self.pool.get('ir.model.data')._update(self.cr, 1, \
'ir.ui.menu', self.module, values, node.id, mode=self.mode, \
noupdate=self.isnoupdate(node), res_id=res and res[0] or False)
action_type = node.type or 'act_window'
action_id = self.get_id(node.action)
action = "ir.actions.%s,%d" % (action_type, action_id)
- self.pool.get('ir.model.data').ir_set(self.cr, self.uid, 'action', \
+ self.pool.get('ir.model.data').ir_set(self.cr, 1, 'action', \
'tree_but_open', 'Menuitem', [('ir.ui.menu', int(parent_id))], action, True, True, xml_id=node.id)
def process_act_window(self, node):
'usage': node.usage,
'limit': node.limit,
'auto_refresh': node.auto_refresh,
+ 'multi': getattr(node, 'multi', False),
}
self._set_group_values(node, values)
if node.target:
values['target'] = node.target
- id = self.pool.get('ir.model.data')._update(self.cr, self.uid, \
+ id = self.pool.get('ir.model.data')._update(self.cr, 1, \
'ir.actions.act_window', self.module, values, node.id, mode=self.mode)
self.id_map[node.id] = int(id)
keyword = 'client_action_relate'
value = 'ir.actions.act_window,%s' % id
replace = node.replace or True
- self.pool.get('ir.model.data').ir_set(self.cr, self.uid, 'action', keyword, \
+ self.pool.get('ir.model.data').ir_set(self.cr, 1, 'action', keyword, \
node.id, [node.src_model], value, replace=replace, noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
# TODO add remove ir.model.data
ids = [self.get_id(node.id)]
if len(ids):
self.pool.get(node.model).unlink(self.cr, self.uid, ids)
- self.pool.get('ir.model.data')._unlink(self.cr, self.uid, node.model, ids)
+ self.pool.get('ir.model.data')._unlink(self.cr, 1, node.model, ids)
else:
self.logger.log(logging.TEST, "Record not deleted.")
res = {'name': node.name, 'url': node.url, 'target': node.target}
- id = self.pool.get('ir.model.data')._update(self.cr, self.uid, \
+ id = self.pool.get('ir.model.data')._update(self.cr, 1, \
"ir.actions.url", self.module, res, node.id, mode=self.mode)
self.id_map[node.id] = int(id)
# ir_set
keyword = node.keyword or 'client_action_multi'
value = 'ir.actions.url,%s' % id
replace = node.replace or True
- self.pool.get('ir.model.data').ir_set(self.cr, self.uid, 'action', \
+ self.pool.get('ir.model.data').ir_set(self.cr, 1, 'action', \
keyword, node.url, ["ir.actions.url"], value, replace=replace, \
noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
else:
value = expression
res[fieldname] = value
- self.pool.get('ir.model.data').ir_set(self.cr, self.uid, res['key'], res['key2'], \
+ self.pool.get('ir.model.data').ir_set(self.cr, 1, res['key'], res['key2'], \
res['name'], res['models'], res['value'], replace=res.get('replace',True), \
isobject=res.get('isobject', False), meta=res.get('meta',None))
for dest, f in (('name','string'), ('model','model'), ('report_name','name')):
values[dest] = getattr(node, f)
assert values[dest], "Attribute %s of report is empty !" % (f,)
- for field,dest in (('rml','report_rml'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')):
+ for field,dest in (('rml','report_rml'),('file','report_rml'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')):
if getattr(node, field):
values[dest] = getattr(node, field)
if node.auto:
self._set_group_values(node, values)
- id = self.pool.get('ir.model.data')._update(self.cr, self.uid, "ir.actions.report.xml", \
+ id = self.pool.get('ir.model.data')._update(self.cr, 1, "ir.actions.report.xml", \
self.module, values, xml_id, noupdate=self.isnoupdate(node), mode=self.mode)
self.id_map[xml_id] = int(id)
keyword = node.keyword or 'client_print_multi'
value = 'ir.actions.report.xml,%s' % id
replace = node.replace or True
- self.pool.get('ir.model.data').ir_set(self.cr, self.uid, 'action', \
+ self.pool.get('ir.model.data').ir_set(self.cr, 1, 'action', \
keyword, values['name'], [values['model']], value, replace=replace, isobject=True, xml_id=xml_id)
def process_none(self):