def test_70_export_attribute_option_with_dependency(self):
        option_model = self.registry('attribute.option')
        binding_option_model = self.registry('magento.attribute.option')
        response = {
            'product_attribute.create':
                self.get_magento_helper('magento.product.attribute').get_next_id,
            'oerp_product_attribute.addOption':
                self.get_magento_helper('magento.attribute.option').get_next_id
        }
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            attr_id, bind_attr_id, code = self.add_attribute(
                'select', 'My Test Select', 'x_test_select')
            option_id = option_model.create(self.cr, self.uid, {
                'attribute_id': attr_id,
                'name': 'My Option',
                })

            option = option_model.browse(self.cr, self.uid, option_id)
            export_record(self.session, 'magento.attribute.option',
                          option.magento_bind_ids[0].id)
            
            self.assertEqual(len(calls_done), 2)
            method, (data,) = calls_done[0]
            self.assertEqual(method, 'product_attribute.create')
            method, (mag_attr_id, data) = calls_done[1]
            self.assertEqual(method, 'oerp_product_attribute.addOption')
    def test_40_export_attribute_char_linked_to_an_attribute_set(self):
        response = {
            'product_attribute.create':
                self.get_magento_helper('magento.product.attribute').get_next_id,
            'product_attribute_set.attributeAdd': True,
        }
        attr_binder = self.get_binder('magento.product.attribute')
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            attr_id, bind_attr_id, code = self.add_attribute(
                'char', 'My Test Char', 'x_test_char')
            self.registry('attribute.location').create(self.cr, self.uid, {
                'attribute_id': attr_id,
                'attribute_group_id': self.attr_group_id,
                })

            export_record(self.session, 'magento.product.attribute',
                          bind_attr_id)
            self.assertEqual(len(calls_done), 2)
            method, (data,) = calls_done[0]
            self.assertEqual(method, 'product_attribute.create')

            method, (mag_attr_id, mag_attr_set_id) = calls_done[1]
            self.assertEqual(method, 'product_attribute_set.attributeAdd')
            self.assertEqual(mag_attr_set_id, self.default_mag_attr_set_id)
            expected_mag_attr_id = attr_binder.to_backend(bind_attr_id)
            self.assertEqual(mag_attr_id, expected_mag_attr_id)
    def test_20_export_attribute_set(self):
        """ Test export of attribute set"""
        response = {
            'product_attribute_set.create': 69,
        }
        cr = self.cr
        uid = self.uid
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            mag_attr_set_model = self.registry('magento.attribute.set')
            attr_set_model = self.registry('attribute.set')

            attr_set_id = attr_set_model.create(cr, uid, {
                'name': 'Test Export Attribute',
                }, {'force_model': 'product.template'})
            mag_attr_set_id = mag_attr_set_model.create(cr, uid, {
                'attribute_set_name': 'Test Export Attribute',
                'openerp_id': attr_set_id,
                'backend_id': self.backend_id,
                })
            
            export_record(self.session, 'magento.attribute.set',
                          mag_attr_set_id)

            self.assertEqual(len(calls_done), 1)

            method, (data, skeleton_id) = calls_done[0]
            self.assertEqual(method, 'product_attribute_set.create')
            self.assertEqual(skeleton_id, '9')
    def setUp(self):
        super(SetUpMagentoSynchronizedWithAttribute, self).setUp()
        with mock_api(magento_attribute_responses):
            import_record(self.session, 'magento.attribute.set',
                          self.backend_id, '9')

        mag_attr_set_model = self.registry('magento.attribute.set')
        attr_set_model = self.registry('attribute.set')
        attr_group_model = self.registry('attribute.group')
        cr, uid = self.cr, self.uid
        self.default_mag_attr_set_id = '9'
        mag_attr_set_ids = mag_attr_set_model.search(cr, uid, [
            ('magento_id', '=', self.default_mag_attr_set_id),
            ('backend_id', '=', self.backend_id),
            ])
        mag_attr_set_id = mag_attr_set_ids[0]
        self.registry('magento.backend').write(cr, uid, self.backend_id, {
            'attribute_set_tpl_id': mag_attr_set_id
            })
        attr_set_id = attr_set_model.create(cr, uid, {
            'name': 'Default Attribute Set',
            }, {'force_model': 'product.template'})

        mag_attr_set_model.write(cr, uid, mag_attr_set_id, {
            'openerp_id': attr_set_id,
            })
        self.default_attr_set_id = attr_set_id

        self.attr_group_id = attr_group_model.create(
            cr, uid, {
                'attribute_set_id': attr_set_id,
                'name': 'openerp',
                }, {'force_model': 'product.template'})
    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], ['openerp_id'])
        order_id = order['openerp_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.openerp_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),
                ('openerp_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')
            self.assertEqual(comment, 'Test me I famous')
    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], ['openerp_id'])
        order_id = order['openerp_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.openerp_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),
                ('openerp_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')
            self.assertEqual(comment, 'Test me I famous')
    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,
                'openerp_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,
                'openerp_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_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,
                    'openerp_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,
                    'openerp_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_export_super_attribute_price(self):
        """ Export Super Attribute Price: check """

        response = {'ol_catalog_product_link.updateSuperAttributeValues': True}
        cr = self.cr
        uid = self.uid
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            dimension_value_model = self.registry('dimension.value')
            mag_super_attribute_model = self.registry(
                'magento.super.attribute')
            mag_attribute_option_model = self.registry(
                'magento.attribute.option')
            dim_value_id = dimension_value_model.create(
                cr, uid, {
                    'dimension_id': 2,
                    'option_id': 7,
                    'price_extra': 0.0,
                    'product_tmpl_id': 56,
                })

            dimension_value_model.write(cr, uid, dim_value_id, {
                'price_extra': 8.0,
            })
            dim_value = dimension_value_model.browse(cr, uid, dim_value_id)

            super_attribute_id = mag_super_attribute_model.search(
                cr, uid, [
                    ('attribute_id', '=', dim_value.dimension_id.id),
                    ('mag_product_display_id.product_tmpl_id', '=',
                     dim_value.product_tmpl_id.id),
                ])[0]
            super_attribute = mag_super_attribute_model.browse(
                cr, uid, super_attribute_id)

            attribute_option_id = mag_attribute_option_model.search(
                cr, uid, [
                    ('openerp_id', '=', dim_value.option_id.id),
                ])[0]
            attribute_option = mag_attribute_option_model.browse(
                cr, uid, attribute_option_id)

            export_record(self.session, 'magento.super.attribute',
                          super_attribute_id)

            self.assertEqual(len(calls_done), 1)

            method, data = calls_done[0]
            magento_super_attribute_id = data[0]
            value_index = data[1][4]['value_index']
            pricing_value = data[1][4]['pricing_value']

            self.assertEqual(
                method, 'ol_catalog_product_link.updateSuperAttributeValues')
            self.assertEqual(magento_super_attribute_id,
                             int(super_attribute.magento_id))
            self.assertEqual(value_index, attribute_option.magento_id)
            self.assertEqual(pricing_value, dim_value.price_extra)
示例#12
0
 def setUp(self):
     super(TestExportPrice, self).setUp()
     with mock_api([simple_product_and_images,
                    magento_base_responses]), mock_urlopen_image():
         import_record(self.session, 'magento.product.product',
                       self.backend_id, 122)
     self.binding = self.env['magento.product.product'].search(
         [('backend_id', '=', self.backend_id),
          ('magento_id', '=', 122),
          ],
     )
示例#13
0
 def import_product(responses):
     with mock_api([responses, magento_base_responses]):
         with mock_urlopen_image():
             import_record(self.session, 'magento.product.product',
                           self.backend_id, 122)
     binding = self.env['magento.product.product'].search(
         [('backend_id', '=', self.backend_id),
          ('magento_id', '=', 122),
          ],
     )
     return binding
示例#14
0
 def _import_order(self):
     with mock_api(magento_base_responses):
         with mock_urlopen_image():
             import_record(self.session,
                           'magento.sale.order',
                           self.backend_id, 900000691)
     binding_model = self.env['magento.sale.order']
     return binding_model.search(
         [('backend_id', '=', self.backend_id),
          ('magento_id', '=', '900000691'),
          ]
     )
    def test_10_import_attribute_set(self):
        """ Import the default attribute set"""
        with mock_api(magento_attribute_responses):
            import_record(self.session, 'magento.attribute.set',
                          self.backend_id, '9')

        mag_attr_obj = self.registry('magento.attribute.set')
        cr, uid = self.cr, self.uid
        mag_attr_set_ids = mag_attr_obj.search(cr, uid, [
            ('magento_id', '=', '9'),
            ('backend_id', '=', self.backend_id),
            ])
        self.assertEqual(len(mag_attr_set_ids), 1)
        mag_attr_set = mag_attr_obj.browse(cr, uid, mag_attr_set_ids[0])
        self.assertEqual(mag_attr_set.attribute_set_name, 'Default')
示例#16
0
    def test_product_change_price_different_pricelist(self):
        """ Export a modified price """
        job_path = ('openerp.addons.magentoerpconnect_pricing.'
                    'product.export_product_price')
        magento_sync_date = fields.Datetime.from_string(self.binding.sync_date)
        magento_sync_date = magento_sync_date.strftime(MAGENTO_DATETIME_FORMAT)
        public_website = self.env['magento.website'].search(
            [('backend_id', '=', self.backend_id),
             ('magento_id', '=', '1')],
            limit=1,
        )
        public_website.pricelist_id = self._create_pricelist()
        response = {
            'ol_catalog_product.update': True,
            'ol_catalog_product.info': {'updated_at': magento_sync_date},
        }
        self.assertEqual(self.binding.list_price, 22)
        with mock_job_delay_to_direct(job_path), \
                mock_api(response, key_func=lambda m, a: m) as calls_done:
            # The write triggers 'on_product_price_changed'
            # which run the job 'export_product_price'.
            # For the test, we force the job to be run directly instead
            # of delayed
            self.binding.list_price = 42
            self.assertEqual(len(calls_done), 3)
            # The first call is 'ol_catalog_product.info', requests
            # the 'updated_at' date to check if the record has changed
            self.assertEqual(calls_done[0][0], 'ol_catalog_product.info')

            # The second call is the update of the 'default' price, on
            # the website with the id '0'
            method, (product_id, values,
                     website_id, id_type) = calls_done[1]
            self.assertEqual(product_id, 122)
            self.assertEqual(values, {'price': 42})
            self.assertEqual(website_id, '0')
            self.assertEqual(id_type, 'id')

            # The third call is the update of the price on the website
            # '1'. Since we have the same pricelist, it should not send
            # a price with this setup
            method, (product_id, values,
                     website_id, id_type) = calls_done[2]
            self.assertEqual(product_id, 122)
            # the pricelist of the website has a surcharge of 10
            self.assertEqual(values, {'price': 52})
            self.assertEqual(website_id, '1')
            self.assertEqual(id_type, 'id')
 def test_50_autobind_attribute_option(self):
     option_model = self.registry('attribute.option')
     binding_option_model = self.registry('magento.attribute.option')
     response = {
         'product_attribute.create':
             self.get_magento_helper('magento.product.attribute').get_next_id,
     }
     with mock_api(response, key_func=lambda m, a: m) as calls_done:
         attr_id, bind_attr_id, code = self.add_attribute(
             'select', 'My Test Select', 'x_test_select')
         option_id = option_model.create(self.cr, self.uid, {
             'attribute_id': attr_id,
             'name': 'My Option',
             })
         option = option_model.browse(self.cr, self.uid, option_id)
         self.assertEqual(len(option.magento_bind_ids), 1)
    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 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_30_export_attribute_char(self):
        response = {
            'product_attribute.create':
                self.get_magento_helper('magento.product.attribute').get_next_id,
        }
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            attr_id, bind_attr_id, code = self.add_attribute(
                'char', 'My Test Char', 'x_test_char')
   
            export_record(self.session, 'magento.product.attribute',
                          bind_attr_id)

            self.assertEqual(len(calls_done), 1)
            method, (data,) = calls_done[0]
            self.assertEqual(method, 'product_attribute.create')
            self.assertEqual(data['attribute_code'], code)
            self.assertEqual(data['frontend_input'], 'text')
示例#21
0
    def test_30_export_category_with_openerp_parent_dependency(self):
        """ Test export of category"""
        response = {
            'catalog_category.create':
            self.get_magento_helper('magento.product.category').get_next_id,
        }
        cr = self.cr
        uid = self.uid
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            mag_categ_model = self.registry('magento.product.category')

            parent_mag_categ_id = mag_categ_model.create(
                cr, uid, {
                    'name': 'My Parent Category',
                    'backend_id': self.backend_id,
                })

            parent_mag_categ = mag_categ_model.browse(cr, uid,
                                                      parent_mag_categ_id)

            mag_categ_id = mag_categ_model.create(
                cr, uid, {
                    'name': 'My Category',
                    'backend_id': self.backend_id,
                    'parent_id': parent_mag_categ.openerp_id.id,
                })

            export_record(self.session, 'magento.product.category',
                          mag_categ_id)

            parent_mag_categ = parent_mag_categ.browse()[0]

            self.assertEqual(len(calls_done), 2)

            method, (parent_id, data) = calls_done[0]
            self.assertEqual(method, 'catalog_category.create')
            self.assertEqual(parent_id, 1)
            self.assertEqual(data['name'], 'My Parent Category')

            method, (parent_id, data) = calls_done[1]
            self.assertEqual(method, 'catalog_category.create')
            self.assertEqual(parent_id, parent_mag_categ.magento_id)
            self.assertEqual(data['name'], 'My Category')
    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], ['openerp_id'])
        order_id = order['openerp_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)
示例#23
0
    def test_20_export_category_with_image(self):
        """ Test export of category"""
        response = {
            'catalog_category.create':
            self.get_magento_helper('magento.product.category').get_next_id,
            'ol_catalog_category_media.create':
            'true',
        }
        cr = self.cr
        uid = self.uid
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            mag_categ_model = self.registry('magento.product.category')
            mag_categ_id = mag_categ_model.create(
                cr, uid, {
                    'name': 'My Category',
                    'image': IMAGE,
                    'image_name': 'myimage.png',
                    'backend_id': self.backend_id,
                })

            export_record(self.session, 'magento.product.category',
                          mag_categ_id, 'image')
            export_product_category_image(self.session,
                                          'magento.product.category',
                                          mag_categ_id, 'image')

            self.assertEqual(len(calls_done), 2)
            method, (parent_id, data) = calls_done[0]
            self.assertEqual(method, 'catalog_category.create')
            self.assertEqual(parent_id, 1)
            self.assertEqual(data['image'], 'myimage.png')
            self.assertEqual(data['thumbnail'], 'myimage.png')
            self.assertEqual(data['name'], 'My Category')

            method, (image_name, image_data) = calls_done[1]
            self.assertEqual(method, 'ol_catalog_category_media.create')
            self.assertEqual(parent_id, 1)
            self.assertEqual(image_name, 'myimage.png')
            self.assertEqual(image_data, IMAGE)
示例#24
0
    def test_export_configurable_product(self):
        """ Export a Configurable Product: check """

        response = {'ol_catalog_product.create': '217'}
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            mag_product_model = self.registry('magento.product.product')

            mag_product_id = mag_product_model.create(
                self.cr, self.uid, {
                    'product_type': 'configurable',
                    'attribute_set_id': self.default_attr_set_id,
                    'default_code': 't-shirt',
                    'description': False,
                    'visibility': '1',
                    'price': 10.0,
                    'weight': 0.0,
                    'website_ids': (),
                    'updated_at': '1970-01-01',
                    'categories': (),
                    'status': '1',
                    'created_at': False,
                    'name': 't-shirt',
                    'description_sale': False,
                    'backend_id': self.backend_id
                })

            export_record(self.session, 'magento.product.product',
                          mag_product_id)
            self.assertEqual(len(calls_done), 1)

            method, data = calls_done[0]
            product_type = data[0]
            attribute_set_id = data[1]
            name = data[2]
            self.assertEqual(method, 'ol_catalog_product.create')
            self.assertEqual(product_type, 'configurable')
            self.assertEqual(attribute_set_id, '9')
            self.assertEqual(name, 't-shirt')
 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,
             'openerp_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')
示例#26
0
    def test_10_export_one_image(self):
        """ Export one Image """
        response = {
            'catalog_product_attribute_media.create':
            self.image_helper.get_next_id,
        }

        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            export_record(self.session, 'magento.product.image',
                          self.mag_image_1_id)

            self.assertEqual(len(calls_done), 1)
            result_expected = {
                'file': {
                    'content': IMAGE,
                    'name': 'image_1',
                    'mime': 'image/jpeg',
                },
                'label': 'image_1',
                'types': ['image', 'small_image', 'thumbnail'],
                'position': 1,
            }
            self.check_image_call(calls_done[0], result_expected)
示例#27
0
    def test_10_export_category(self):
        """ Test export of category"""
        response = {
            'catalog_category.create':
            self.get_magento_helper('magento.product.category').get_next_id,
        }
        cr = self.cr
        uid = self.uid
        with mock_api(response, key_func=lambda m, a: m) as calls_done:
            mag_categ_model = self.registry('magento.product.category')
            mag_categ_id = mag_categ_model.create(
                cr, uid, {
                    'name': 'My Category',
                    'backend_id': self.backend_id,
                })

            export_record(self.session, 'magento.product.category',
                          mag_categ_id)

            self.assertEqual(len(calls_done), 1)
            method, (parent_id, data) = calls_done[0]
            self.assertEqual(method, 'catalog_category.create')
            self.assertEqual(parent_id, 1)
 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,
                 'openerp_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')
    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], ['openerp_id'])
        order_id = order['openerp_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)