and
are actually UTF-8 \xa0 characters (non-breaking
# spaces)!
assert """\
""" in html
def test_build_root_namespace_view(self):
self.apb.build_namespace_pages()
self.linker.replace_dirpath(self.base, False)
rootfile = self.base.join('api/index.html')
assert rootfile.check()
html = rootfile.read()
assert '' in html
_checkhtml(html)
def test_get_revision(self):
py.test.skip('XXX changed implementation (temporarily?)')
if py.std.sys.platform.startswith('win'):
py.test.skip('broken on win32 for some reason (svn caching?), '
'skipping')
# XXX a lot of setup required for this one... more like a functional
# test I fear
# create test repo and checkout
repo = make_test_repo('test_get_revision_api_repo')
wc = py.path.svnwc(py.test.ensuretemp('test_get_revision_api_wc'))
wc.checkout(repo.url)
assert wc.status().rev == '0'
# create a temp package inside the working copy
fs_root, pkg_name = setup_fs_project(wc)
ds, dsa = get_dsa(self.fs_root, self.pkg_name)
wc.commit('test get revision commit')
wc.update()
# clear cache
py.__.apigen.htmlgen._get_obj_cache = {}
# fiddle about a bit with paths so that our package is picked up :|
old_path = py.std.sys.path
try:
py.std.sys.path.insert(0, fs_root.strpath)
pkgkeys = [k for k in py.std.sys.modules.keys() if
k == 'pkg' or k.startswith('pkg.')]
# remove modules from sys.modules
for key in pkgkeys:
del py.std.sys.modules[key]
# now create a new apb that uses the wc pkg
apb = ApiPageBuilder(self.base, self.linker, dsa,
fs_root.join(pkg_name),
self.namespace_tree, self.project)
apb._revcache = {} # clear cache, this is on class level!!
pkg = wc.join('pkg')
assert pkg.check(versioned=True)
assert pkg.info().created_rev == 1
funcpath = pkg.join('func.py')
classpath = pkg.join('someclass.py')
assert funcpath.check(versioned=True)
assert classpath.check(versioned=True)
assert apb.get_revision('main.sub.func') == 1
assert apb.get_revision('main.SomeClass') == 1
assert apb.get_revision('') == 1
assert apb.get_revision('main.sub') == 1
funcpath.write(funcpath.read() + '\n')
funcpath.commit('updated func')
wc.update()
apb._revcache = {} # clear cache
assert apb.get_revision('main.sub.func') == 2
assert apb.get_revision('') == 1
assert apb.get_revision('main.SomeClass') == 1
finally:
py.std.sys.path = old_path
# clear caches again
py.__.apigen.htmlgen._get_obj_cache = {}
apb._revcache = {}
class TestSourcePageBuilder(AbstractBuilderTest):
def test_build_pages(self):
self.spb.build_pages(self.fs_root)
somesource = self.base.join('source/pkg/func.py.html').read()
_checkhtml(somesource)
def test_build_pages_nav(self):
self.spb.build_pages(self.fs_root)
self.linker.replace_dirpath(self.base, False)
funcsource = self.base.join('source/pkg/func.py.html')
assert funcsource.check(file=True)
html = funcsource.read()
print html
run_string_sequence_test(html, [
'href="../style.css"',
'pkg',
'
someclass.py',
'
somesubclass.py',
])
def test_build_dir_page(self):
self.spb.build_pages(self.fs_root)
self.linker.replace_dirpath(self.base, False)
pkgindex = self.base.join('source/pkg/index.html')
assert pkgindex.check(file=True)
html = pkgindex.read()
print html
run_string_sequence_test(html, [
'href="../style.css"',
'
pkg',
'
func.py',
'
someclass.py',
'
somesubclass.py',
'
directories
',
'
files
'])
_checkhtml(html)
def test_build_source_page(self):
self.spb.build_pages(self.fs_root)
self.linker.replace_dirpath(self.base, False)
funcsource = self.base.join('source/pkg/func.py.html')
assert funcsource.check(file=True)
html = funcsource.read()
print html
assert ('
def func(arg1)') in html
def test_build_navigation_root(self):
self.spb.build_pages(self.fs_root)
self.linker.replace_dirpath(self.base)
html = self.base.join('source/pkg/index.html').read()
print html
run_string_sequence_test(html, [
'href="index.html">pkg',
'href="func.py.html">func.py',
'href="someclass.py.html">someclass.py',
'href="somesubclass.py.html">somesubclass.py',
])
def test_get_revision(self):
py.test.skip('XXX changed implementation (temporarily?)')
if py.std.sys.platform.startswith('win'):
py.test.skip('broken on win32 for some reason (svn caching?), '
'skipping')
repo = make_test_repo('test_get_revision_source_repo')
wc = py.path.svnwc(py.test.ensuretemp('test_get_revision_source_wc'))
wc.checkout(repo.url)
dir = wc.ensure('dir', dir=True)
file = dir.ensure('file.py', file=True)
wc.commit('added dir and file')
wc.update()
assert file.check(versioned=True)
assert wc.status().rev == '1'
assert self.spb.get_revision(dir) == 1
assert self.spb.get_revision(file) == 1
file.write('while 1:\n print "py lib is cool\n"')
file.commit('added some code')
assert file.status().rev == '2'
self.spb._revcache = {}
assert self.spb.get_revision(file) == 2
assert self.spb.get_revision(dir) == 1