Ejemplo n.º 1
0
    def test_2_export_partner_address(self):
        """ Test export of address"""
        partner_helper = self.get_magento_helper('magento.res.partner')
        address_helper = self.get_magento_helper('magento.address')
        response = {
            'customer_address.create': address_helper.get_next_id,
        }
        cr = self.cr
        uid = self.uid
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            mag_address_model = self.registry('magento.address')
            mag_partner_model = self.registry('magento.res.partner')
            mag_partner_id = mag_partner_model.create(
                cr, uid, {
                    'website_id': self.website_id,
                    'odoo_id': self.partner_id2,
                    'magento_id': partner_helper.get_next_id(),
                })
            mag_address_id = mag_address_model.create(cr, uid, {
                'magento_partner_id': mag_partner_id,
                'odoo_id': self.address,
            })
            export_record(self.session, 'magento.address', mag_address_id)

            self.assertEqual(len(calls_done), 1)

            method, [partner, values] = calls_done[0]
            self.assertEqual(method, 'customer_address.create')
            self.assertEqual(values['postcode'], '11112')
            self.assertEqual(values['city'], 'City contact test2')
            self.assertEqual(values['street'], '15, contact test street2')
            self.assertEqual(values['country_id'], 'BE')
            self.assertEqual(values['telephone'], '111111112')
    def test_10_import_sale_comment_for_edited_sale_order(self):
        """ Test import of sale order comment for edited sale order
        Note: the parent have been note cancel in the magento_base_response
        because we want to import the both sale order.
        """
        cr = self.cr
        uid = self.uid
        backend_id = self.backend_id
        with mock_api(magento_base_responses):
            with mock_urlopen_image():
                import_record(self.session, 'magento.sale.order', backend_id,
                              '900000691-1')
                order_model = self.registry('magento.sale.order')
        mag_order_ids = order_model.search(cr, uid, [
            ('backend_id', '=', backend_id),
            ('magento_id', '=', '900000691-1'),
        ])
        self.assertEqual(len(mag_order_ids), 1)

        order = order_model.read(cr, uid, mag_order_ids[0], ['odoo_id'])
        order_id = order['odoo_id'][0]

        comment_ids = self.registry('magento.sale.comment').search(
            cr, uid, [
                ('backend_id', '=', backend_id),
                ('res_id', '=', order_id),
            ])
        # The sale order 900000691 have 1 comment
        # and the 900000691-1 have 2 comment
        # Total is 3 comment
        self.assertEqual(len(comment_ids), 3)
    def test_20_export_sale_comment(self):
        """ Test export of sale order comment"""
        response = {
            'sales_order.addComment': True,
        }
        cr = self.cr
        uid = self.uid
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            mag_comment_model = self.registry('magento.sale.comment')
            mail_message_model = self.registry('mail.message')

            comment_id = mail_message_model.create(
                cr, uid, {
                    'res_id': self.mag_order.odoo_id.id,
                    'body': 'Test me I famous',
                    'model': 'sale.order',
                    'subtype_id': 1,
                })

            mag_comment_id = mag_comment_model.search(cr, uid, [
                ('backend_id', '=', self.backend_id),
                ('odoo_id', '=', comment_id),
            ])[0]

            export_record(self.session, 'magento.sale.comment', mag_comment_id)

            self.assertEqual(len(calls_done), 1)

            method, (mag_order_id, state, comment, notif) = calls_done[0]
            self.assertEqual(method, 'sales_order.addComment')
            self.assertEqual(mag_order_id, '900000691')
            # the comment is in <p> so BeautifulSoup adds a final \n
            self.assertEqual(comment.rstrip('\n'), 'Test me I famous')
    def setUp(self):
        super(SetUpMagentoWithSaleOrder, self).setUp()
        cr = self.cr
        uid = self.uid
        mag_order_model = self.registry('magento.sale.order')
        with mock_api(magento_base_responses):
            with mock_urlopen_image():
                import_record(self.session, 'magento.sale.order',
                              self.backend_id, 900000691)

        mag_order_ids = mag_order_model.search(cr, uid, [
            ('backend_id', '=', self.backend_id),
            ('magento_id', '=', '900000691'),
        ])

        self.mag_order = mag_order_model.browse(cr, uid, mag_order_ids[0])
    def test_10_import_sale_comment(self):
        """ Test import of sale order comment"""
        cr = self.cr
        uid = self.uid
        backend_id = self.backend_id
        with mock_api(magento_base_responses):
            with mock_urlopen_image():
                import_record(self.session, 'magento.sale.order', backend_id,
                              900000695)
                order_model = self.registry('magento.sale.order')
        mag_order_ids = order_model.search(cr, uid, [
            ('backend_id', '=', backend_id),
            ('magento_id', '=', '900000695'),
        ])
        self.assertEqual(len(mag_order_ids), 1)

        order = order_model.read(cr, uid, mag_order_ids[0], ['odoo_id'])
        order_id = order['odoo_id'][0]
        comment_ids = self.registry('magento.sale.comment').search(
            cr, uid, [('backend_id', '=', backend_id),
                      ('res_id', '=', order_id)])
        self.assertEqual(len(comment_ids), 2)
Ejemplo n.º 6
0
 def test_1_export_partner(self):
     """ Test export of partner"""
     partner_helper = self.get_magento_helper('magento.res.partner')
     address_helper = self.get_magento_helper('magento.address')
     response = {
         'customer.create': partner_helper.get_next_id,
         'customer_address.create': address_helper.get_next_id,
     }
     cr = self.cr
     uid = self.uid
     with mock_api(response, key_func=lambda m, a: m) as calls_done:
         mag_partner_model = self.registry('magento.res.partner')
         mag_partner_id = mag_partner_model.create(
             cr, uid, {
                 'website_id': self.website_id,
                 'odoo_id': self.partner_id,
             })
         export_record(self.session, 'magento.res.partner', mag_partner_id)
         self.assertEqual(len(calls_done), 3)
         method, [values] = calls_done[0]
         self.assertEqual(method, 'customer.create')
         self.assertEqual(values['email'], '*****@*****.**')
         self.assertEqual(values['firstname'], 'Partner')
         self.assertEqual(values['lastname'], 'Partnerbis')