summaryrefslogtreecommitdiff
path: root/tests/test-hgwebdir-paths.py
diff options
context:
space:
mode:
authorLorry <lorry@roadtrain.codethink.co.uk>2012-08-22 14:49:51 +0100
committerLorry <lorry@roadtrain.codethink.co.uk>2012-08-22 14:49:51 +0100
commita498da43c7fdb9f24b73680c02a4a3588cc62d9a (patch)
treedaf8119dae1749b5165b68033a1b23a7375ce9ce /tests/test-hgwebdir-paths.py
downloadmercurial-tarball-a498da43c7fdb9f24b73680c02a4a3588cc62d9a.tar.gz
Tarball conversion
Diffstat (limited to 'tests/test-hgwebdir-paths.py')
-rw-r--r--tests/test-hgwebdir-paths.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test-hgwebdir-paths.py b/tests/test-hgwebdir-paths.py
new file mode 100644
index 0000000..b9118b3
--- /dev/null
+++ b/tests/test-hgwebdir-paths.py
@@ -0,0 +1,40 @@
+import os
+from mercurial import hg, ui
+from mercurial.hgweb.hgwebdir_mod import hgwebdir
+
+os.mkdir('webdir')
+os.chdir('webdir')
+
+webdir = os.path.realpath('.')
+
+u = ui.ui()
+hg.repository(u, 'a', create=1)
+hg.repository(u, 'b', create=1)
+os.chdir('b')
+hg.repository(u, 'd', create=1)
+os.chdir('..')
+hg.repository(u, 'c', create=1)
+os.chdir('..')
+
+paths = {'t/a/': '%s/a' % webdir,
+ 'b': '%s/b' % webdir,
+ 'coll': '%s/*' % webdir,
+ 'rcoll': '%s/**' % webdir}
+
+config = os.path.join(webdir, 'hgwebdir.conf')
+configfile = open(config, 'w')
+configfile.write('[paths]\n')
+for k, v in paths.items():
+ configfile.write('%s = %s\n' % (k, v))
+configfile.close()
+
+confwd = hgwebdir(config)
+dictwd = hgwebdir(paths)
+
+assert len(confwd.repos) == len(dictwd.repos), 'different numbers'
+assert len(confwd.repos) == 9, 'expected 9 repos, found %d' % len(confwd.repos)
+
+found = dict(confwd.repos)
+for key, path in dictwd.repos:
+ assert key in found, 'repository %s was not found' % key
+ assert found[key] == path, 'different paths for repo %s' % key