# 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
    %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(
            environ={'argv':[random.randint(1,100)]},
        ).setup_environ()

        self.assertTrue(all([path in sys.path for path in random_paths]))

    def test_raises_importerror_on_bad_router(self):
        self.mox.StubOutWithMock(config, 'build_settings')
        settings = """
[%s]
routers=dne.dne.dne
        """.strip() % config.SECTION_NAME
        config.build_settings().AndReturn(create_settings(settings))
        self.mox.ReplayAll()

        # this time we care that things are broken.
        self.assertRaises(ImportError, serve.ServeApp.run)

    def test_delegates_properly(self):
        self.mox.StubOutWithMock(config, 'build_settings')
        settings = """
[%s]
routers=tests.serve

# 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

    %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(
            environ={'argv':[random.randint(1,100)]},
        ).setup_environ()

        self.assertTrue(all([path in sys.path for path in random_paths]))

    def test_raises_importerror_on_bad_router(self):
        self.mox.StubOutWithMock(config, 'build_settings')
        settings = """
[%s]
routers=dne.dne.dne
        """.strip() % config.SECTION_NAME
        config.build_settings().AndReturn(create_settings(settings))
        self.mox.ReplayAll()

        # this time we care that things are broken.
        self.assertRaises(ImportError, serve.ServeApp.run)

    def test_delegates_properly(self):
        self.mox.StubOutWithMock(config, 'build_settings')
        settings = """
[%s]
routers=tests.serve

auth=tests.gittests.test_utils.AllAuth