# Path: intuition/errors.py
# class LoadMarketSchemeFailed(dna.errors.FactoryError):
#     msg = "Failed to load market scheme: {reason}"


import os
import unittest
import dna.test_utils
import intuition.data.universe as universe
from nose.tools import raises, eq_
from intuition.errors import LoadMarketSchemeFailed
        tmp_path = self.scheme_path.replace('market', 'bkp.market')
        os.system('mv {} {}'.format(self.scheme_path, tmp_path))
        self.assertRaises(LoadMarketSchemeFailed, universe.Market)
        os.system('mv {} {}'.format(tmp_path, self.scheme_path))

    def test__extract_forex(self):
        market = universe.Market()
        sids = market._extract_forex()
        self.assertGreater(len(sids), 0)
        self.assertGreater(sids[0].find('/'), 0)

    def test__extract_cac40(self):
        market = universe.Market()
        sids = market._extract_cac40(['stocks', 'paris', 'cac40'])
        self.assertGreater(len(sids), 0)
        self.assertGreater(sids[0].find('.pa'), 0)

    def test__lookup_sids_no_limit(self):
        market = universe.Market()
        sids = market._lookup_sids(self.good_universe_description)
        self.assertIsInstance(sids, list)
        self.assertGreater(len(sids), 0)

    def test__lookup_sids_with_limit(self):
        limit = 4
        market = universe.Market()
        sids = market._lookup_sids(self.good_universe_description, limit)
        self.assertIsInstance(sids, list)
        eq_(len(sids), limit)


# Path: intuition/errors.py
# class LoadMarketSchemeFailed(dna.errors.FactoryError):
#     msg = "Failed to load market scheme: {reason}"


# Path: tests/data/test_universe.py
import os
import unittest
import dna.test_utils
import intuition.data.universe as universe
from nose.tools import raises, eq_
from intuition.errors import LoadMarketSchemeFailed

        tmp_path = self.scheme_path.replace('market', 'bkp.market')
        os.system('mv {} {}'.format(self.scheme_path, tmp_path))
        self.assertRaises(LoadMarketSchemeFailed, universe.Market)
        os.system('mv {} {}'.format(tmp_path, self.scheme_path))

    def test__extract_forex(self):
        market = universe.Market()
        sids = market._extract_forex()
        self.assertGreater(len(sids), 0)
        self.assertGreater(sids[0].find('/'), 0)

    def test__extract_cac40(self):
        market = universe.Market()
        sids = market._extract_cac40(['stocks', 'paris', 'cac40'])
        self.assertGreater(len(sids), 0)
        self.assertGreater(sids[0].find('.pa'), 0)

    def test__lookup_sids_no_limit(self):
        market = universe.Market()
        sids = market._lookup_sids(self.good_universe_description)
        self.assertIsInstance(sids, list)
        self.assertGreater(len(sids), 0)

    def test__lookup_sids_with_limit(self):
        limit = 4
        market = universe.Market()
        sids = market._lookup_sids(self.good_universe_description, limit)
        self.assertIsInstance(sids, list)
        eq_(len(sids), limit)


    @raises(LoadMarketSchemeFailed)