Files
odoo_source/addons/edi/test/edi_partner_test.yml
T
Olivier Dony 5f24594223 [IMP] edi: work-in-progress: remove permanent storage of edi.document
The EDI documents will now be generated on demand
and available from the Portal view of each document.
Instead of getting a link to a statically generated
EDI document, customers will receive a link to
the portal access to the document. They will be able
to signup on the portal the first time as well,
provided they are using the secure token that was
sent to them (i.e. the right link).

The link to pay online will be available in the
portal as well.

Still much to do, this is a small first step,
with edi.document renamed to edi.edi for
consistency, as it will not persist any
edi.document anymore.

bzr revid: odo@openerp.com-20121011152008-bht7ub6woaex0a7u
2012-10-11 17:20:08 +02:00

42 lines
2.4 KiB
YAML

-
In order to test the basic EDI system, I will export a partner,
modify the exported EDI document to add an attachment and change
the data, and then re-import it and re-export it.
with an attached file, check the result, the alter the data
and reimport it.
-
!python {model: edi.edi}: |
import json
res_partner = self.pool.get('res.partner')
doc = self.generate_edi(cr, uid, [res_partner.browse(cr, uid, ref('base.res_partner_2'))])
edi_doc, = json.loads(doc)
# check content of the document
assert edi_doc.get('__id').endswith('.res_partner_2'), 'Incorrect external ID'
assert edi_doc.get('__model') == 'res.partner', 'Incorrect/Missing __model'
assert edi_doc.get('__module') == 'base', 'Incorrect/Missing __module'
assert edi_doc.get('__last_update'), 'Missing __last_update'
# try to import the document after changing the name and id, and attaching a
# file, and check that a new partner is returned
edi_doc['__id'] = 'base:xxd37f8a-xx55-11e0-xxdd-xx81124c8b50.res_partner_xxx'
edi_doc['name'] = 'AgroMilk'
attachment = {
'name': 'Test file',
'file_name': 'test.png',
# base64 standard requires blocks of 57bytes=76chars, NL-separated
'content': 'iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A\n/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oIDQ84BkjLWAYAAACNSURBVCjP\njZKxDUJBDEOf/wbUbEHDhkxAzRjUDECBhMQYjIApuPBNpK+PpUinOPYll5Nt1iCJXifbSPpJZtHg\nXLUdu0FWpMEt87a/xtsmqjjNetPFyhuWYFuj7RcgQBNwXNGdw2CqY85yXWi5z7YBnmRyEHvg0YSX\nrLE9P30nwugOHHr+s5va4x+fofAGm1+JjnJICm0AAAAASUVORK5CYII=\n',
}
edi_doc['__attachments'] = [attachment]
doc = json.dumps([edi_doc])
result, = self.import_edi(cr, uid, edi_document=doc)
assert result[0] == 'res.partner' and result[1] > ref('base.res_partner_2'),\
"Expected (%r,> %r) after import 1, got %r" % ('res.partner', ref('base.res_partner_2'), result)
# export the same partner we just created, and see if the output matches the input
doc_output = self.generate_edi(cr, uid, [res_partner.browse(cr, uid, result[1])])
edi_doc_output, = json.loads(doc_output)
for attribute in ('__model', '__module', '__id', 'name', '__attachments'):
assert edi_doc_output.get(attribute) == edi_doc.get(attribute), \
'Incorrect value for %s, expected %r, got %r' % (attribute, edi_doc.get(attribute), edi_doc_output.get(attribute))