def setUp(self):
        Base.metadata.create_all()

        instrument = Instrument()
        instrument.ticker = 'MyTicker'
        instrument.asset_class = 'MyAssetClass'
        instrument.name = 'MyName'
        instrument.currency = 'USD'
        instrument.type = 'MyType'
        instrument.transactions_fees = 0.
        instrument.point_value = 1
        instrument.exchange = 'MyExchange'
        instrument.rolling_month = 'H'
        
        market_data = MarketData()
        market_data.instrument = instrument
        market_data.type = DataType.CLOSE
        market_data.date = datetime(2000,1,3)
        market_data.value = 100.
        
        session = Session()
        
        instrument_dao = InstrumentDAO()
        instrument_dao.save(session, instrument)
        
        market_data_dao = MarketDataDAO()
        market_data_dao.save(session, market_data)
        
        
        self.instrument_service = InstrumentService() 
 def testDAO(self):
     data = MarketData()
     data.type = self.type
     data.value = self.value
     data.date = self.date
     data.instrument = self.instrument
     
     market_data_dao = MarketDataDAO()
     
     # test save
     market_data_dao.save(self.session, data)
     self.assertNotEqual(data.id, None, 'market data id')
     self.assertEqual(data.type, self.type, 'market data type')
     self.assertEqual(data.value, self.value, 'market data value')
     self.assertEqual(data.date, self.date, 'market data date')
     self.assertEqual(data.instrument_id, self.instrument.id, 'market data type')
     
     # test get by instrument
     new_data = market_data_dao.get_by_instrument(self.session, self.instrument)
     self.assertEqual(new_data[0].id, data.id, 'both ids equals')
     
     last_date = market_data_dao.get_last_date(self.session, self.instrument)
     self.assertEqual(last_date, data.date)
     # test delete
     market_data_dao.delete(self.session, data)