# Path: insights/test_framework.py
# class FactoryManagerTestCase(unittest.TestCase):
#     '''
#     This abstract factory class targets the same achievements as the
#     FactoryAlgorithmTestCase, focusing on Intuition managers building block.
#     '''
# 
#     __metaclass__ = abc.ABCMeta
# 
#     def setUp(self):
#         setup_logger(self)
#         self.some_date = dt.datetime(2014, 04, 10)
#         self.buy_signal = {'goog': 34}
#         self.test_sids = ['goog', 'aapl', 'msft']
#         self.test_pf = generate_fake_portfolio(self.test_sids)
# 
#     def tearDown(self):
#         teardown_logger(self)
# 
#     @nottest
#     def _check_initialization(self, manager):
#         ok_(not manager.date)
#         ok_(not manager.portfolio)
#         ok_(not manager.perfs)
#         ok_(hasattr(manager, 'log'))
# 
#     @nottest
#     def _check_optimize_return(self, alloc, e_ret, e_risk):
#         ok_(isinstance(alloc, dict))
#         ok_(e_ret >= 0 and e_ret <= 1)
#         ok_(e_risk >= 0 and e_risk <= 1)


from nose.tools import eq_
from insights.test_framework import FactoryManagerTestCase
import insights.managers.linear as linear
    def test_optimize_empty_signals(self):
        manager = linear.Constant({})
        alloc, e_ret, e_risk = manager.optimize({}, {})
        self._check_optimize_return(alloc, e_ret, e_risk)
        eq_(alloc, {})
        eq_(e_ret, 0)
        eq_(e_risk, 1)

    def test_optimize_buy_signals(self):
        manager = linear.Constant({})
        alloc, e_ret, e_risk = manager.optimize(
            to_buy=self.buy_signal, to_sell={})
        self._check_optimize_return(alloc, e_ret, e_risk)
        eq_(alloc, {'goog': self.default_amount})

    def test_optimize_buy_signals_custom_amount(self):
        manager = linear.Constant({'buy_amount': 200})
        alloc, e_ret, e_risk = manager.optimize(
            to_buy=self.buy_signal, to_sell={})
        self._check_optimize_return(alloc, e_ret, e_risk)
        eq_(alloc, {'goog': 200})

    def test_optimize_buy_signals_init_custom_amount(self):
        manager = linear.Constant({'buy_amount': 200})
        alloc, e_ret, e_risk = manager.optimize(
            to_buy=self.buy_signal, to_sell={})
        self._check_optimize_return(alloc, e_ret, e_risk)
        eq_(alloc, {'goog': 200})



# Path: insights/test_framework.py
# class FactoryManagerTestCase(unittest.TestCase):
#     '''
#     This abstract factory class targets the same achievements as the
#     FactoryAlgorithmTestCase, focusing on Intuition managers building block.
#     '''
# 
#     __metaclass__ = abc.ABCMeta
# 
#     def setUp(self):
#         setup_logger(self)
#         self.some_date = dt.datetime(2014, 04, 10)
#         self.buy_signal = {'goog': 34}
#         self.test_sids = ['goog', 'aapl', 'msft']
#         self.test_pf = generate_fake_portfolio(self.test_sids)
# 
#     def tearDown(self):
#         teardown_logger(self)
# 
#     @nottest
#     def _check_initialization(self, manager):
#         ok_(not manager.date)
#         ok_(not manager.portfolio)
#         ok_(not manager.perfs)
#         ok_(hasattr(manager, 'log'))
# 
#     @nottest
#     def _check_optimize_return(self, alloc, e_ret, e_risk):
#         ok_(isinstance(alloc, dict))
#         ok_(e_ret >= 0 and e_ret <= 1)
#         ok_(e_risk >= 0 and e_risk <= 1)


# Path: tests/managers/test_linear.py
from nose.tools import eq_
from insights.test_framework import FactoryManagerTestCase
import insights.managers.linear as linear

    def test_optimize_empty_signals(self):
        manager = linear.Constant({})
        alloc, e_ret, e_risk = manager.optimize({}, {})
        self._check_optimize_return(alloc, e_ret, e_risk)
        eq_(alloc, {})
        eq_(e_ret, 0)
        eq_(e_risk, 1)

    def test_optimize_buy_signals(self):
        manager = linear.Constant({})
        alloc, e_ret, e_risk = manager.optimize(
            to_buy=self.buy_signal, to_sell={})
        self._check_optimize_return(alloc, e_ret, e_risk)
        eq_(alloc, {'goog': self.default_amount})

    def test_optimize_buy_signals_custom_amount(self):
        manager = linear.Constant({'buy_amount': 200})
        alloc, e_ret, e_risk = manager.optimize(
            to_buy=self.buy_signal, to_sell={})
        self._check_optimize_return(alloc, e_ret, e_risk)
        eq_(alloc, {'goog': 200})

    def test_optimize_buy_signals_init_custom_amount(self):
        manager = linear.Constant({'buy_amount': 200})
        alloc, e_ret, e_risk = manager.optimize(
            to_buy=self.buy_signal, to_sell={})
        self._check_optimize_return(alloc, e_ret, e_risk)
        eq_(alloc, {'goog': 200})



class FairManagerTestCase(FactoryManagerTestCase):