mirror of
https://github.com/kennethreitz-archive/sphinx-to-github.git
synced 2026-06-05 23:40:17 +00:00
e98c23737e
Tests for Layout, LayoutFactory and setup(app). Resulted in structuring some code so that LayoutFactory uses other factories to generate the helpers and handlers for the Layout.
47 lines
986 B
Python
47 lines
986 B
Python
|
|
from sphinxtogithub.tests import MockExists, MockRemove
|
|
|
|
import sphinxtogithub
|
|
import unittest
|
|
|
|
class MockHandler(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.processed = False
|
|
|
|
def process(self):
|
|
|
|
self.processed = True
|
|
|
|
|
|
|
|
class TestLayout(unittest.TestCase):
|
|
|
|
def testProcess(self):
|
|
|
|
directory_handlers = []
|
|
file_handlers = []
|
|
|
|
for i in range(0, 10):
|
|
directory_handlers.append(MockHandler())
|
|
for i in range(0, 5):
|
|
file_handlers.append(MockHandler())
|
|
|
|
layout = sphinxtogithub.Layout(directory_handlers, file_handlers)
|
|
|
|
layout.process()
|
|
|
|
# Check all handlers are processed by reducing them with "and"
|
|
self.assert_(reduce(lambda x, y: x and y.processed, directory_handlers, True))
|
|
self.assert_(reduce(lambda x, y: x and y.processed, file_handlers, True))
|
|
|
|
|
|
def testSuite():
|
|
suite = unittest.TestSuite()
|
|
|
|
suite.addTest(TestLayout("testProcess"))
|
|
|
|
return suite
|
|
|