# Path: nappingcat/serve.py
# class ServeApp(App):
#     def create_request(self, cmdpatterns):
#     def setup_environ(self):
#     def main(self):
# 
# Path: nappingcat/config.py
# SECTION_NAME = 'kittyconfig' 
# def build_settings():
# def setup_environ(settings):
# 
# Path: nappingcat/request.py
# class Request(object):
#     def __init__(self, user, command, settings, streams, root_patterns):
# 
# Path: nappingcat/exceptions.py
# class NappingCatBadConfig(NappingCatException):
#     pass
# 
# Path: nappingcat/patterns.py
# def patterns(path, *args):
#     return CommandPatterns(path, args) 


from unittest import TestCase
from nappingcat import serve
from nappingcat import config
from nappingcat import request
from nappingcat.exceptions import NappingCatBadConfig
from nappingcat.patterns import patterns
import mox
import random
import sys
import ConfigParser
import StringIO
    def setUp(self):
        self.mox = mox.Mox()

    def tearDown(self):
        self.mox.UnsetStubs()

    def test_bad_config(self):
        self.mox.StubOutWithMock(config, 'build_settings')
        settings = """
[something]
this_does_not_matter=nope
        """.strip()        
        config.build_settings().AndReturn(create_settings(settings))
        self.mox.ReplayAll()
        self.assertRaises(NappingCatBadConfig, serve.ServeApp.run)
    def test_inserts_into_sys_path(self):
        self.mox.StubOutWithMock(config, 'build_settings')
        random_paths = ['rand-%d' for i in range(0,3)]
        settings = """
[%s]
paths = 
    %s
    %s
    %s
        """.strip() % (config.SECTION_NAME, random_paths[0], random_paths[1], random_paths[2]) 
        config.build_settings().AndReturn(create_settings(settings))
        self.mox.ReplayAll()


        # we don't really care about this assertion.

# Path: nappingcat/serve.py
# class ServeApp(App):
#     def create_request(self, cmdpatterns):
#     def setup_environ(self):
#     def main(self):
# 
# Path: nappingcat/config.py
# SECTION_NAME = 'kittyconfig' 
# def build_settings():
# def setup_environ(settings):
# 
# Path: nappingcat/request.py
# class Request(object):
#     def __init__(self, user, command, settings, streams, root_patterns):
# 
# Path: nappingcat/exceptions.py
# class NappingCatBadConfig(NappingCatException):
#     pass
# 
# Path: nappingcat/patterns.py
# def patterns(path, *args):
#     return CommandPatterns(path, args) 


# Path: tests/serve.py
from unittest import TestCase
from nappingcat import serve
from nappingcat import config
from nappingcat import request
from nappingcat.exceptions import NappingCatBadConfig
from nappingcat.patterns import patterns
import mox
import random
import sys
import ConfigParser
import StringIO

    def setUp(self):
        self.mox = mox.Mox()

    def tearDown(self):
        self.mox.UnsetStubs()

    def test_bad_config(self):
        self.mox.StubOutWithMock(config, 'build_settings')
        settings = """
[something]
this_does_not_matter=nope
        """.strip()        
        config.build_settings().AndReturn(create_settings(settings))
        self.mox.ReplayAll()
        self.assertRaises(NappingCatBadConfig, serve.ServeApp.run)
    def test_inserts_into_sys_path(self):
        self.mox.StubOutWithMock(config, 'build_settings')
        random_paths = ['rand-%d' for i in range(0,3)]
        settings = """
[%s]
paths = 
    %s
    %s
    %s
        """.strip() % (config.SECTION_NAME, random_paths[0], random_paths[1], random_paths[2]) 
        config.build_settings().AndReturn(create_settings(settings))
        self.mox.ReplayAll()


        # we don't really care about this assertion.

        serve.ServeApp(