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.
62 lines
1.3 KiB
Python
62 lines
1.3 KiB
Python
|
|
from sphinxtogithub.tests import MockExists, MockRemove, MockStream
|
|
|
|
import sphinxtogithub
|
|
import unittest
|
|
import os
|
|
|
|
|
|
|
|
class MockRename(object):
|
|
|
|
def __call__(self, from_, to):
|
|
self.from_ = from_
|
|
self.to = to
|
|
|
|
class TestForceRename(unittest.TestCase):
|
|
|
|
def testCall(self):
|
|
|
|
rename = MockRename()
|
|
remove = MockRemove()
|
|
renamer = sphinxtogithub.ForceRename(rename, remove)
|
|
|
|
from_ = "from"
|
|
to = "to"
|
|
renamer(from_, to)
|
|
|
|
self.assertEqual(rename.from_, from_)
|
|
self.assertEqual(rename.to, to)
|
|
self.assertEqual(remove.name, to)
|
|
|
|
|
|
class TestVerboseRename(unittest.TestCase):
|
|
|
|
def testCall(self):
|
|
|
|
rename = MockRename()
|
|
stream = MockStream()
|
|
renamer = sphinxtogithub.VerboseRename(rename, stream)
|
|
|
|
from_ = os.path.join("path", "to", "from")
|
|
to = os.path.join("path", "to", "to")
|
|
renamer(from_, to)
|
|
|
|
self.assertEqual(rename.from_, from_)
|
|
self.assertEqual(rename.to, to)
|
|
self.assertEqual(
|
|
stream.msgs[0],
|
|
"Renaming directory '%s' -> '%s'\n" % (os.path.basename(from_), os.path.basename(to))
|
|
)
|
|
|
|
|
|
|
|
def testSuite():
|
|
suite = unittest.TestSuite()
|
|
|
|
suite.addTest(TestForceRename("testCall"))
|
|
suite.addTest(TestVerboseRename("testCall"))
|
|
|
|
return suite
|
|
|