[Treepkg-commits] r399 - in branches/treepkg-status: bin test treepkg
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Aug 6 13:06:09 CEST 2010
Author: bricks
Date: 2010-08-06 13:06:08 +0200 (Fri, 06 Aug 2010)
New Revision: 399
Modified:
branches/treepkg-status/bin/publishdebianpackages.py
branches/treepkg-status/bin/publishpackages.py
branches/treepkg-status/test/test_info.py
branches/treepkg-status/test/test_util.py
branches/treepkg-status/treepkg/publish.py
branches/treepkg-status/treepkg/util.py
Log:
cleanup modules
fix test_info testcases
added testcases for remove_trailingslashes and expand_filename
Modified: branches/treepkg-status/bin/publishdebianpackages.py
===================================================================
--- branches/treepkg-status/bin/publishdebianpackages.py 2010-08-05 16:21:47 UTC (rev 398)
+++ branches/treepkg-status/bin/publishdebianpackages.py 2010-08-06 11:06:08 UTC (rev 399)
@@ -20,10 +20,9 @@
from treepkg.readconfig import read_config_section, convert_bool
from treepkg.run import call, capture_output
from treepkg.cmdexpand import cmdexpand
-from treepkg.publish import copy_arch_to_publishdir, expand_filename, \
- prefix_for_remote_command, remove_trailing_slashes
+from treepkg.publish import copy_arch_to_publishdir, prefix_for_remote_command
-from treepkg.util import md5sum
+from treepkg.util import md5sum, expand_filename, remove_trailing_slashes
from treepkg.info.status import TreepkgInfo
from treepkg.info.data import Package
from treepkg.info.data import CacheDb
@@ -83,11 +82,6 @@
**variables))
return TreepkgInfo.fromxml(xml)
-def get_binary_arch(arch):
- if not arch is None and not arch.startswith("binary") and arch != "source":
- arch = "binary-" + arch
- return arch
-
def check_package_is_new(packagename, destdir, packagemd5sum):
destpackage = os.path.join(destdir, packagename)
if not os.path.isfile(destpackage):
Modified: branches/treepkg-status/bin/publishpackages.py
===================================================================
--- branches/treepkg-status/bin/publishpackages.py 2010-08-05 16:21:47 UTC (rev 398)
+++ branches/treepkg-status/bin/publishpackages.py 2010-08-06 11:06:08 UTC (rev 399)
@@ -19,8 +19,8 @@
from treepkg.readconfig import read_config_section, convert_bool
from treepkg.run import call, capture_output
from treepkg.cmdexpand import cmdexpand
-from treepkg.util import ensure_directory, listdir_abs
-from treepkg.publish import remove_trailing_slashes, expand_filename
+from treepkg.util import ensure_directory, listdir_abs, \
+ remove_trailing_slashes, expand_filename
from treepkg.publish import prefix_for_remote_command, copy_to_publishdir
config_desc = ["distribution", "section", "num_newest",
Modified: branches/treepkg-status/test/test_info.py
===================================================================
--- branches/treepkg-status/test/test_info.py 2010-08-05 16:21:47 UTC (rev 398)
+++ branches/treepkg-status/test/test_info.py 2010-08-06 11:06:08 UTC (rev 399)
@@ -11,15 +11,11 @@
import os
import sys
-test_dir = os.path.dirname(__file__)
-sys.path.append(os.path.join(test_dir, os.pardir))
-
from treepkg.info.status import TreepkgInfo, TreepkgRootInfo
from filesupport import FileTestMixin
+from treepkg.publish import get_binary_arch
-from publishdebianpackages import get_binary_arch
-
class TreepkgInfoTest(unittest.TestCase, FileTestMixin):
config_contents = """\
[DEFAULT]
@@ -83,7 +79,7 @@
xml = dom.toxml()
self.assertEquals("<info><name>testtreepkg</name></info>", xml)
-class TestPublishDebianPackages(unittest.TestCase, FileTestMixin):
+class TestPublish(unittest.TestCase, FileTestMixin):
def test_get_binary_arch(self):
source = get_binary_arch("source")
Modified: branches/treepkg-status/test/test_util.py
===================================================================
--- branches/treepkg-status/test/test_util.py 2010-08-05 16:21:47 UTC (rev 398)
+++ branches/treepkg-status/test/test_util.py 2010-08-06 11:06:08 UTC (rev 399)
@@ -12,9 +12,11 @@
from filesupport import FileTestMixin
-from treepkg.util import replace_in_file, listdir_abs, md5sum
+from treepkg.util import replace_in_file, listdir_abs, md5sum, \
+ remove_trailing_slashes, expand_filename
+
class TestReplaceInFile(unittest.TestCase, FileTestMixin):
def runtest(self, orig_contents, expected_contents, pattern, replacement):
@@ -82,3 +84,21 @@
def test_md5sum(self):
sum = md5sum(self.testfile)
self.assertEquals("a12511153555c1f0f0a1eda200733a3f", sum)
+
+class TestRemoveTrailingSlashes(unittest.TestCase):
+
+ def test_remove_trailing_slashes(self):
+ dir_w_slash = "/tmp/dir/"
+ dir_wo_slash = "/tmp/dir"
+
+ self.assertEquals(dir_wo_slash, remove_trailing_slashes(dir_w_slash))
+ self.assertEquals(dir_wo_slash, remove_trailing_slashes(dir_wo_slash))
+
+class TestExpandFilename(unittest.TestCase):
+
+ def test_expand_filenam(self):
+ os.environ['MY_TEST_VAR'] = "def"
+ path = "/abc/${MY_TEST_VAR}/"
+
+ self.assertEquals("/abc/def/", expand_filename(path))
+
Modified: branches/treepkg-status/treepkg/publish.py
===================================================================
--- branches/treepkg-status/treepkg/publish.py 2010-08-05 16:21:47 UTC (rev 398)
+++ branches/treepkg-status/treepkg/publish.py 2010-08-06 11:06:08 UTC (rev 399)
@@ -13,15 +13,6 @@
from treepkg.run import call, capture_output
from treepkg.cmdexpand import cmdexpand
-def remove_trailing_slashes(s):
- return s.rstrip("/")
-
-def expand_filename(filename):
- """
- Applies os.path.expanduser and os.path.expandvars to filename
- """
- return os.path.expandvars(os.path.expanduser(filename))
-
def prefix_for_remote_command(user, host):
"""Returns the ssh call needed to run a command on a remote host.
If host is empty, the function assumes the command is to be run on
@@ -97,4 +88,8 @@
rsync_flags=rsync_flags, remote_destdir=remote_destdir,
**variables))
+def get_binary_arch(arch):
+ if not arch is None and not arch.startswith("binary") and arch != "source":
+ arch = "binary-" + arch
+ return arch
Modified: branches/treepkg-status/treepkg/util.py
===================================================================
--- branches/treepkg-status/treepkg/util.py 2010-08-05 16:21:47 UTC (rev 398)
+++ branches/treepkg-status/treepkg/util.py 2010-08-06 11:06:08 UTC (rev 399)
@@ -174,3 +174,13 @@
f.close()
return m.hexdigest()
+def remove_trailing_slashes(s):
+ return s.rstrip("/")
+
+def expand_filename(filename):
+ """
+ Applies os.path.expanduser and os.path.expandvars to filename
+ """
+ return os.path.expandvars(os.path.expanduser(filename))
+
+
More information about the Treepkg-commits
mailing list