def checkBarcode(self, event): import Util.Barcode as Barcode bc = self.text_ctrl_barcode.GetValue() if not Barcode.validateBarcode(bc): wx.MessageDialog(self, "That barcode is wrong!", "Barcode Error", wx.OK | wx.ICON_HAND).ShowModal() else: if bc[0] == "0" or len(bc) == 12: self.choice_country.SetSelection(1) else: self.choice_country.SetSelection(0) res = getAmazonInfoByUPC(bc) if res: self.amazonStore = res[0] self.amazonASIN = res[1] self._setInfoLabel(self.button_amazon, "%s (%s)" % (res[1], res[0])) self.coverjpg = res[2] else: self._setInfoLabel(self.button_amazon, "not found")
def testNonNumeric(self): for bc in ("0000000000X", "Barcode123456"): result = Barcode.validateBarcode(bc) self.assertFalse(result)
def testTooLong(self): for i in range(14, 20): bc = "0" * i result = Barcode.validateBarcode(bc) self.assertFalse(result)
def testTooShort(self): for i in range(0, 11): bc = "0" * i result = Barcode.validateBarcode(bc) self.assertFalse(result)
def testKnownValues(self): for bc, expectedResult in self.knownValues: print bc result = Barcode.validateBarcode(bc) self.assertEqual(result, expectedResult)
def testTooLong(self): for i in range(14,20): bc = "0" * i result = Barcode.validateBarcode(bc) self.assertFalse(result)
def testTooShort(self): for i in range(0,11): bc = "0" * i result = Barcode.validateBarcode(bc) self.assertFalse(result)