def test_currencies(self): cases = [ (u'2.40', 2.4), (u'2', 2.0), (u'-2.40', -2.4), (u'-2', -2.0), (u'"2,000.40"', 2000.4), (u'"-2,000.40"', -2000.4), (u'£2.40', 2.4), (u'-£2.40', -2.4), (u'0.00', 0.0), (u'0', 0.0), ] for amount, expected in cases: rec = importModel.CsvRecordItem(u'07/08/2016,Some Company,%s' % amount) sign = 1 if expected < 1 else -1 rec.formatItem(0, 1, 2, 2, sign, 'dd/MM/yyyy') self.assertEqual(rec.dataDict().get('debit'), expected * sign)
def notest_debit_withSign_pound(self): rec = importModel.CsvRecordItem(u'07/08/2016,Some Company,-£2.40') rec.formatItem(0, 1, 2, 2, 1, 'dd/MM/yyyy') self.assertEqual(rec.dataDict().get('debit'), -2.4) self.assertEqual(rec.dataDict().get('credit'), None)
def setUp(self): raw = u'07/08/2016,Some Company,£2.40' self.rec = importModel.CsvRecordItem(raw) self.rec.formatItem(0, 1, 2, 2, -1, 'dd/MM/yyyy') self.data = self.rec.dataDict()