From 6b4cc648d4bb145683c40980d3f19417abaa8d76 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Tue, 1 Mar 2011 16:29:11 +0530 Subject: [PATCH] [ADD/REF] sync_google_contact: Added a yaml to import only addresses. Improved yaml to import addresses and create partners. bzr revid: uco@tinyerp.com-20110301105911-koi6h6p73o43z9x4 --- addons/sync_google_contact/__openerp__.py | 5 ++- ...st_sync_google_contact_import_address.yml} | 25 ++++++------- ...est_sync_google_contact_import_partner.yml | 36 +++++++++++++++++++ 3 files changed, 53 insertions(+), 13 deletions(-) rename addons/sync_google_contact/test/{test_sync_google_contact.yml => test_sync_google_contact_import_address.yml} (69%) create mode 100644 addons/sync_google_contact/test/test_sync_google_contact_import_partner.yml diff --git a/addons/sync_google_contact/__openerp__.py b/addons/sync_google_contact/__openerp__.py index d2255342cd8..5ccd486fb33 100644 --- a/addons/sync_google_contact/__openerp__.py +++ b/addons/sync_google_contact/__openerp__.py @@ -33,7 +33,10 @@ 'wizard/google_contact_import_view.xml' ], 'demo_xml': [], - 'test': ['test/test_sync_google_contact.yml'], + 'test': [ + 'test/test_sync_google_contact_import_address.yml', + 'test/test_sync_google_contact_import_partner.yml', + ], 'installable': True, 'active': False, 'certificate': '', diff --git a/addons/sync_google_contact/test/test_sync_google_contact.yml b/addons/sync_google_contact/test/test_sync_google_contact_import_address.yml similarity index 69% rename from addons/sync_google_contact/test/test_sync_google_contact.yml rename to addons/sync_google_contact/test/test_sync_google_contact_import_address.yml index 5442d49e737..116288ee252 100644 --- a/addons/sync_google_contact/test/test_sync_google_contact.yml +++ b/addons/sync_google_contact/test/test_sync_google_contact_import_address.yml @@ -1,33 +1,34 @@ - In order to test Importing contacts from any google account into OpenERP, - I use a gmail account and import the contact details. -- + I use a gmail account and import the contact details and store them as Partner addresses. +- | I create a record for the gmail account for which I want to import the contacts. -- +- !record {model: google.login.contact, id: google_login_contact_id0}: user: testmail.openerp password: openerptiny -- +- | I login into that account. - !python {model: google.login.contact}: | self.check_login(cr, uid, [ref('google_login_contact_id0')], context) -- - Now I select from which group I want to get the contact details and I want to create partner for all contacts. +- | + Now I select from which group I want to get the contact details. - !record {model: synchronize.google.contact.import, id: synchronize_google_contact_import_id0}: - create_partner: create_all + create_partner: create_address group_name: all -- - I import the contacts. +- | + I import the contacts and I also check if the contact already exists in db and updates the address. - !python {model: synchronize.google.contact.import}: | self.import_contact(cr, uid, [ref('synchronize_google_contact_import_id0')], context) -- - I check whether the contacts are created or not. +- | + I check whether the Contacts are created in Partner address or not. - !python {model: ir.model.data}: | - addr_ids = self.pool.get('res.partner.address').search(cr, uid, []) + addr_obj = self.pool.get('res.partner.address') + addr_ids = addr_obj.search(cr, uid, []) data_ids = self.search(cr, uid, [('res_id','in',addr_ids),('model','=','res.partner.address'),('module','=','sync_google_contact')]) assert data_ids, 'Addresses not created !' \ No newline at end of file diff --git a/addons/sync_google_contact/test/test_sync_google_contact_import_partner.yml b/addons/sync_google_contact/test/test_sync_google_contact_import_partner.yml new file mode 100644 index 00000000000..eda1972d04d --- /dev/null +++ b/addons/sync_google_contact/test/test_sync_google_contact_import_partner.yml @@ -0,0 +1,36 @@ +- + In order to test Importing contacts from any google account into OpenERP, + I use a gmail account and import the contact details and create Partners. +- | + I create a record for the gmail account for which I want to import the contacts. +- + !record {model: google.login.contact, id: google_login_contact_id1}: + user: testmail.openerp + password: openerptiny +- | + I login into that account. +- + !python {model: google.login.contact}: | + self.check_login(cr, uid, [ref('google_login_contact_id1')], context) +- | + Now I select from which group I want to get the contact details and I want to create partner for all contacts. +- + !record {model: synchronize.google.contact.import, id: synchronize_google_contact_import_id1}: + create_partner: create_all + group_name: all +- | + I import the contacts. +- + !python {model: synchronize.google.contact.import}: | + self.import_contact(cr, uid, [ref('synchronize_google_contact_import_id1')], context) +- | + I check whether the Partners are created or not. +- + !python {model: ir.model.data}: | + addr_obj = self.pool.get('res.partner.address') + addr_ids = addr_obj.search(cr, uid, []) + data_ids = self.search(cr, uid, [('res_id','in',addr_ids),('model','=','res.partner.address'),('module','=','sync_google_contact')]) + address_ids = map(lambda x: x.res_id, [child for child in self.browse(cr, uid, data_ids) if child.res_id]) + partner_ids = map(lambda x: x.partner_id.id, [addr for addr in addr_obj.browse(cr, uid, address_ids) if addr.partner_id]) + assert partner_ids, 'Partners not created !' + \ No newline at end of file