def test_write_file_for_product_list(self): """ Test data writer for product list. :return: """ # file_path = os.path.join(settings.JSON_DIR_PATH, "%s_list.json" % Product._meta.model_name) data = get_products_data_with_mock(self.fake_data_path, 'products', nb_files=3) file = Product.write_api_data(data) self.assertTrue(os.path.exists(file))
def test_get_data_for_product_element(self): """ Test data writer for product element. :return: """ # file_path = os.path.join(settings.JSON_DIR_PATH, "%s.json" % Product._meta.model_name) with open(os.path.join(self.fake_data_path, '3222472887966.json'), 'r') as file: fake_data_product = file.read() with requests_mock.Mocker() as mock: mock.get(Product.get_element_api_url( self.product_id), text=fake_data_product) data = Product.get_api_data_element(self.product_id) file = Product.write_api_data(data) self.assertTrue(os.path.exists(file))