# Path: intuition/errors.py
# class InvalidConfiguration(dna.errors.FactoryError):
#     msg = "invalid configuration: {reason} ({config})"


import unittest
import dna.test_utils as test_utils
import pandas as pd
import intuition.core.configuration as configuration
from nose.tools import raises
from dna.errors import DynamicImportFailed
from intuition.errors import InvalidConfiguration
            'intuition.test_utils.FakeContext://localhost/path?valid=false'
        self.bad_formatted_config = \
            'intuition.test_utils.FakeContext://localhost/path?format=false'

    def tearDown(self):
        test_utils.teardown_logger(self)

    def test_load_context(self):
        with configuration.Context(self.good_driver) as context:
            self.assertIsInstance(context, dict)
            self.assertIsInstance(context['strategy'], dict)
            self.assertIsInstance(context['config'], dict)

    @raises(InvalidConfiguration)
    def test_validate_bad_config(self):
        bad_config = {}
        ctx = configuration.Context(self.bad_driver)
        ctx._validate(bad_config)

    def test_validate_good_config(self):
        good_config = {
            'universe': 'nasdaq,4',
            'index': pd.date_range('2014/2/3', periods=30),
            'modules': {
                'algorithm': 'dualma'
            }
        }
        ctx = configuration.Context(self.bad_driver)
        self.assertIsNone(ctx._validate(good_config))


# Path: intuition/errors.py
# class InvalidConfiguration(dna.errors.FactoryError):
#     msg = "invalid configuration: {reason} ({config})"


# Path: tests/core/test_configuration.py
import unittest
import dna.test_utils as test_utils
import pandas as pd
import intuition.core.configuration as configuration
from nose.tools import raises
from dna.errors import DynamicImportFailed
from intuition.errors import InvalidConfiguration

            'intuition.test_utils.FakeContext://localhost/path?valid=false'
        self.bad_formatted_config = \
            'intuition.test_utils.FakeContext://localhost/path?format=false'

    def tearDown(self):
        test_utils.teardown_logger(self)

    def test_load_context(self):
        with configuration.Context(self.good_driver) as context:
            self.assertIsInstance(context, dict)
            self.assertIsInstance(context['strategy'], dict)
            self.assertIsInstance(context['config'], dict)

    @raises(InvalidConfiguration)
    def test_validate_bad_config(self):
        bad_config = {}
        ctx = configuration.Context(self.bad_driver)
        ctx._validate(bad_config)

    def test_validate_good_config(self):
        good_config = {
            'universe': 'nasdaq,4',
            'index': pd.date_range('2014/2/3', periods=30),
            'modules': {
                'algorithm': 'dualma'
            }
        }
        ctx = configuration.Context(self.bad_driver)
        self.assertIsNone(ctx._validate(good_config))


    @raises(InvalidConfiguration)