# Path: nappingcat/config.py
# SECTION_NAME = 'kittyconfig' 
# def build_settings():
# def setup_environ(settings):


from unittest import TestCase
from nappingcat import config
import mox
import os
import ConfigParser
import random
import shutil

    def test_reads_from_appropriate_path_and_file(self):
        f = open(self.filename, 'w')
        print >>f,"""
[kittyconfig]
blah=3
        """.strip()
        f.flush()
        f.close()

        self.mox.StubOutWithMock(os.path, 'expanduser')
        os.path.expanduser(mox.IsA(str)).AndReturn(self.filename)
        self.mox.ReplayAll()
        results = config.build_settings()
        self.assertTrue(isinstance(results, ConfigParser.ConfigParser))
        self.mox.VerifyAll()

    def test_raises_parsingerror_with_bad_config(self):
        f = open(self.filename, 'w')
        print >>f,"""
[kittyconfig
blah=3
anrranl;faksdj
        """.strip()
        f.flush()
        f.close()

        self.mox.StubOutWithMock(os.path, 'expanduser')
        os.path.expanduser(mox.IsA(str)).AndReturn(self.filename)
        self.mox.ReplayAll()

# Path: nappingcat/config.py
# SECTION_NAME = 'kittyconfig' 
# def build_settings():
# def setup_environ(settings):


# Path: tests/config.py
from unittest import TestCase
from nappingcat import config
import mox
import os
import ConfigParser
import random
import shutil


    def test_reads_from_appropriate_path_and_file(self):
        f = open(self.filename, 'w')
        print >>f,"""
[kittyconfig]
blah=3
        """.strip()
        f.flush()
        f.close()

        self.mox.StubOutWithMock(os.path, 'expanduser')
        os.path.expanduser(mox.IsA(str)).AndReturn(self.filename)
        self.mox.ReplayAll()
        results = config.build_settings()
        self.assertTrue(isinstance(results, ConfigParser.ConfigParser))
        self.mox.VerifyAll()

    def test_raises_parsingerror_with_bad_config(self):
        f = open(self.filename, 'w')
        print >>f,"""
[kittyconfig
blah=3
anrranl;faksdj
        """.strip()
        f.flush()
        f.close()

        self.mox.StubOutWithMock(os.path, 'expanduser')
        os.path.expanduser(mox.IsA(str)).AndReturn(self.filename)
        self.mox.ReplayAll()

        self.assertRaises(ConfigParser.Error, config.build_settings)