def testDefaultView(self): '''Test the default view''' self.fill() funds = PortfolioHolder.objects.filter(parent = None) # pick a random fund holder = funds[randint(0,len(funds)-1)] funds = holder.dates.all() fund = funds[randint(0,len(funds)-1)] # call the api to obtain the view view = api.get_portfolio_object(fund) self.assertEqual(view.portfolio,fund) self.assertEqual(view.name,'default') self.assertEqual(view.ccy,fund.ccy) folders = view.folders.all() self.assertTrue(folders.count()>0) #The total number of positions in folders #must be the same as the number of position in porfolio N = 0 for folder in folders: N += folder.positions.size() self.assertEqual(N,fund.positions.all().count())
def testDefaultView(self): '''Test the default view''' self.fill() funds = PortfolioHolder.objects.filter(parent=None) # pick a random fund holder = funds[randint(0, len(funds) - 1)] funds = holder.dates.all() fund = funds[randint(0, len(funds) - 1)] # call the api to obtain the view view = api.get_portfolio_object(fund) self.assertEqual(view.portfolio, fund) self.assertEqual(view.name, 'default') self.assertEqual(view.ccy, fund.ccy) folders = view.folders.all() self.assertTrue(folders.count() > 0) #The total number of positions in folders #must be the same as the number of position in porfolio N = 0 for folder in folders: N += folder.positions.size() self.assertEqual(N, fund.positions.all().count())
def get_id(self, name, dt=None): fund = Fund.objects.get(code=name) instance = api.get_portfolio_object(fund) return api.get_object_id(instance, dt)
def get_id(self, name, dt = None): fund = Fund.objects.get(code = name) instance = api.get_portfolio_object(fund) return api.get_object_id(instance,dt)