def _check_export_was_called(self, func): job_path = ('openerp.addons.prime_catalog_connector.models' '.prime_catalog_backend.export_product_job') with mock_job_delay_to_direct(job_path): func() self.assertEqual(1, self.mock_data.num_calls)
def _export(self): job_path = ('openerp.addons.prime_catalog_connector.models' '.prime_catalog_backend.export_product_job') with mock_job_delay_to_direct(job_path): catalog_backend = self.env['prime.catalog.backend'].create({ 'name': 'Test Backend', 'version': '0.1', 'url': 'empty url', }) catalog_backend.export_products()
def test_10_export_one_product(self): product = self.env.ref('product.product_product_3_product_template') si_variant = product.shopinvader_bind_ids[0].shopinvader_variant_ids[0] with mock_job_delay_to_direct(self.path): si_variant._scheduler_export(domain=[('id', '=', si_variant.id)]) # If someone else has a less ugly solution, I'm interrested. time.sleep(5) client = algoliasearch.client.Client(self.se_backend.algolia_app_id, self.se_backend.algolia_api_key) index = client.initIndex(si_variant.index_id.name) algolia_product = index.search(si_variant.name) self.assertEqual(algolia_product['nbHits'], 1) self.assertEqual(algolia_product['hits'][0]['model_name'], si_variant.name) self.assertEqual(int(algolia_product['hits'][0]['objectID']), product.id) self.assertEqual(algolia_product['hits'][0]['default_code'], si_variant.default_code)
def test_export_product(self): path = ('openerp.addons.connector_nosql_algolia.' 'unit.exporter.export_record') expected_ids = [] for xml_id in (3, 4): tmpl = self.env.ref('product.product_product_%s_product_template' % xml_id) binding = self.env['nosql.product.template'].create({ 'backend_id': self.backend.id, 'record_id': tmpl.id, 'index_id': self.index.id, }) expected_ids.append(binding.id) with mock_job_delay_to_direct(path), mock_api() as API: self.env['nosql.product.template']._scheduler_export() # Check that only one index have been call self.assertEqual(len(API.index), 1) # Check that only right index have been call index_name = API.index.keys()[0] self.assertEqual(index_name, self.index.name) # Check the call done calls = API.index[index_name]._calls self.assertEqual(len(calls), 1) # Check the method call method, params = calls[0] self.assertEqual(method, 'add_objects') # Check the product exported exported_ids = [p['objectID'] for p in params] self.assertEqual(exported_ids, expected_ids)
def confirm_sale(self): with mock_job_delay_to_direct(self.job_path): self.cart.action_button_confirm()
def _set_payment_method(self): with mock_job_delay_to_direct(self.job_path): self.service.update({ 'payment_method_id': self.payment_method.id, 'next_step': self.backend.last_step_id.code })
def test_30_export_all_categories(self): with mock_job_delay_to_direct(self.path): self.backend.export_all_category()
def test_20_export_all_products(self): with mock_job_delay_to_direct(self.path): self.backend.export_all_product()