class CreaProdsTest(unittest.TestCase): @classmethod def setUpTestData(cls): cls.cat = create_from_breadcrumbs('Prueba') cls.pc = ProductClass.objects.create(name='Subcomponent') cls.partner = Partner.objects.create(name='Loaded') cls.part_number = ProductAttribute.objects.create( product_class=cls.pc, name='Part number', code='PN', required=True, type=ProductAttribute.TEXT) def setUp(self): self.realDB = DBAccess('Prueba') def test_productos_sin_partnumber__regresaRunTimeError(self): self.assertRaises(RuntimeError, self.realDB.create_prods, self.cat, True, 'Hey', None, 'Man', 'ori', '1', '0.00', '0.00', '0.00') def test_productos_partnumber_string_empty__regresaRunTimeError(self): self.assertRaises(RuntimeError, self.realDB.create_prods, self.cat, True, 'Hey', '', 'Man', 'ori', '1', '0.00', '0.00', '0.00') def test_agregarDiagNumMayor5Caracteres_LevantaDatabaseError(self): self.assertRaises(DatabaseError, self.realDB.create_prods, self.cat, True, 'Prod', '1', 'Man', 'Origin', 'pppppp', '0.00', '0.00', '0.00') def test_incluirPreciosPriceExclTaxComa_OK(self): prod = self.realDB.create_prods(self.cat, True, 'Prod', '1', 'Man', 'Origin', 'pppppp', '1,002.00', '0.00', '0.00') self.assertEqual(prod.title, 'Prod') def test_incluirPreciosPriceExclTax_OK(self): prod = self.realDB.create_prods(self.cat, True, 'Prod', '1', 'Man', 'Origin', 'pppppp', '2.00', '0.00', '0.00') self.assertEqual(prod.title, 'Prod') def test_incluirPreciosPriceExclTaxComa_regresaInvalidOperation(self): self.assertRaises(InvalidOperation, self.realDB.create_prods, self.cat, True, 'Prod', '1', 'Man', 'Origin', 'pppppp', '', '0.00', '0.00')
def exec_excel_load(path_arch, cat, cat_base, nom_manufac, nom_origin): return excel_load( cat, DBAccess(cat_base), ExcelHandler().leer(path_arch), nom_manufac, nom_origin )
def setUp(self): self.excel_stub = TestExcelHandler() self.db = DBAccess("Base")
def ejec_cargador(caminoArch, cat_base, verbosity): if verbosity: logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.ERROR) fh = FileHandler() return extraer_prods(fh.leer(caminoArch), DBAccess(cat_base))
def setUp(self): self.realDB = DBAccess("catBase")
def setUp(self): self.realDB = DBAccess('Prueba')
def exec_excel_load(path, cat, base_cate, manufac_name, origin_name): return excel_load(cat, DBAccess(base_cate), ExcelHandler().read(path), manufac_name, origin_name)
def exec_loader(path, base_cat, verbosity): fh = FileHandler() return extract_prods(fh.read(path), DBAccess(base_cat))