def testFile2(self): inputFile = join(getCurrentDirectory(), 'samples', 'missing fund name.xls') try: readFile(inputFile) except: pass # expected: fund name not found else: self.fail('Error should occur, but didn\'t')
def testFile1(self): inputFile = join(getCurrentDirectory(), 'samples', 'wrong fund name.xls') try: readFile(inputFile) except: pass # expected: unsupported fund name else: self.fail('Error should occur, but didn\'t')
def testFile3(self): inputFile = join(getCurrentDirectory(), 'samples', '06 multiple cash multiple bond.xls') positions = list(readFile(inputFile)) cashPositions = list( filter(lambda p: p['AssetType'] == 'Cash', positions)) self.assertEqual(3, len(cashPositions)) cnyHTMBonds = list(filter( lambda p: p['AssetType'] == 'HTMBond' and \ p['Currency'] == 'CNY' , positions)) self.assertEqual(1, len(cnyHTMBonds)) self.verifyCNYHTMBondPosition(cnyHTMBonds[0]) usdAFSBonds = compose( list, partial( filter, lambda p: p['AssetType'] == 'AFSBond' and p['Currency'] == 'USD'))(positions) self.assertEqual(4, len(usdAFSBonds)) self.verifyUSDAFSBondPosition(usdAFSBonds[3]) self.assertEqual( 67, countPositions( lambda p: p['AssetType'] == 'HTMBond' and p['Currency'] == 'USD', positions))
def testFile1(self): inputFile = join(getCurrentDirectory(), 'samples', '01 cash only.xls') positions = list(readFile(inputFile)) self.assertEqual(4, len(positions)) cashPositions = list( filter(lambda p: p['AssetType'] == 'Cash', positions)) self.assertEqual(3, len(cashPositions)) self.verifyCashPosition(cashPositions[0])
def testFile2(self): inputFile = join(getCurrentDirectory(), 'samples', '03 cash equity.xls') positions = list(readFile(inputFile)) self.assertEqual(4, len(positions)) equityPositions = list( filter(lambda p: p['AssetType'] == 'Equity', positions)) self.assertEqual(1, len(equityPositions)) self.verifyEquityPosition(equityPositions[0])
def testFile4(self): inputFile = join(getCurrentDirectory(), 'samples', '05 cash multiple bond.xls') positions = list(readFile(inputFile)) self.assertEqual( 2, countPositions(lambda p: p['AssetType'] == 'Cash', positions)) self.assertEqual( 4, countPositions( lambda p: p['AssetType'] == 'AFSBond' and p['Currency'] == 'USD', positions)) usdHTMBonds = list( filter( lambda p: p['AssetType'] == 'HTMBond' and p['Currency'] == 'USD', positions)) self.assertEqual(51, len(usdHTMBonds)) self.verifyUSDHTMBondPosition(usdHTMBonds[0])