def test_LogReportProductNotFound_returnLog(self): self.st.throw_does_not_exists = True updater(test_data, self.st) #self.handler.flush() self.assertEqual( self.log_buf.getvalue(), "WARNING - Product with part number 1 does not exists. Skipping update.\n" "WARNING - Product with part number 2 does not exists. Skipping update.\n" "WARNING - Product with part number 3 does not exists. Skipping update.\n" "WARNING - Product with part number 4 does not exists. Skipping update.\n" )
def test_LogReportMultiplesProductFound_returnLog(self): self.st.throw_mult_objs = True updater(test_data, self.st) #self.handler.flush() self.assertEqual( self.log_buf.getvalue(), 'WARNING - Multiple Products with part number 1. Skipping update for those ones.\n' 'WARNING - Multiple Products with part number 2. Skipping update for those ones.\n' 'WARNING - Multiple Products with part number 3. Skipping update for those ones.\n' 'WARNING - Multiple Products with part number 4. Skipping update for those ones.\n' )
def test_WrongValuePrices_returnLog(self): stats = updater(test_data_bad_prices, self.st) self.assertEqual( self.log_buf.getvalue(), 'WARNING - Wrong value. Skipping product with part number 1\n' 'WARNING - Wrong value. Skipping product with part number 2\n')
def test_WrongValuePrices_return2(self): stats = updater(test_data_bad_prices, self.st) self.assertEqual(stats['not_found'], 2) self.assertEqual(stats['total'], 2)
def test_MultiplesProductNotFound_returns4(self): self.st.throw_mult_objs = True stats = updater(test_data, self.st) self.assertEqual(stats['not_found'], 4) self.assertEqual(stats['total'], 4)
def test_NotFoundProduct_notfound4(self): self.st.throw_does_not_exists = True stats = updater(test_data, self.st) self.assertEqual(stats['not_found'], 4) self.assertEqual(stats['total'], 4)
def test_updateAllProducts_updated4(self): stats = updater(test_data, self.st) self.assertEqual(stats['updated'], 4) self.assertEqual(stats['total'], 4)
def test_createAllProducts_created4(self): self.st.created = True stats = updater(test_data, self.st) self.assertEqual(stats['created'], 4) self.assertEqual(stats['total'], 4)
def test_productListEmpty_return0(self): stats = updater([], self.st) self.assertEqual(stats['total'], 0) self.assertEqual(self.log_buf.getvalue(), '')