Permalink
Browse files

Modules tar and zip promoted into main package

  • Loading branch information...
1 parent 4b05068 commit d778df6b4f520a0be94335912f34c278400ce6f1 @dvarrazzo committed Sep 4, 2012
Showing with 20 additions and 18 deletions.
  1. +2 −2 pgxnclient/archive.py
  2. +2 −1 pgxnclient/tar.py
  3. +14 −14 pgxnclient/tests/test_commands.py
  4. +2 −1 pgxnclient/zip.py
View
@@ -23,12 +23,12 @@ def from_file(filename):
"""
# Get the metadata from an archive file
if filename.endswith('.zip'):
- from pgxnclient.utils.zip import ZipArchive
+ from pgxnclient.zip import ZipArchive
return ZipArchive(filename)
else:
# Tar files have many naming variants. Let's not
# guess them.
- from pgxnclient.utils.tar import TarArchive
+ from pgxnclient.tar import TarArchive
return TarArchive(filename)
View
@@ -14,7 +14,8 @@
from pgxnclient.archive import Archive
import logging
-logger = logging.getLogger('pgxnclient.utils.tar')
+logger = logging.getLogger('pgxnclient.tar')
+
class TarArchive(Archive):
"""Handle .tar archives"""
@@ -324,10 +324,10 @@ def assertCallArgs(self, pattern, args):
# With mock patching a method seems tricky: looks there's no way to get to
# 'self' as the mock method is unbound.
-from pgxnclient.utils.tar import TarArchive
+from pgxnclient.tar import TarArchive
TarArchive.unpack_orig = TarArchive.unpack
-from pgxnclient.utils.zip import ZipArchive
+from pgxnclient.zip import ZipArchive
ZipArchive.unpack_orig = ZipArchive.unpack
class InstallTestCase(unittest.TestCase, Assertions):
@@ -417,7 +417,7 @@ def test_install_sudo(self):
self.assertCallArgs(['gksudo', '-d', 'hello world', self.make],
self.mock_popen.call_args_list[1][0][0][:4])
- @patch('pgxnclient.utils.tar.TarArchive.unpack')
+ @patch('pgxnclient.tar.TarArchive.unpack')
def test_install_local_tar(self, mock_unpack):
fn = get_test_filename('foobar-0.42.1.tar.gz')
mock_unpack.side_effect = TarArchive(fn).unpack_orig
@@ -435,7 +435,7 @@ def test_install_local_tar(self, mock_unpack):
tmpdir, = mock_unpack.call_args[0]
self.assertEqual(make_cwd, os.path.join(tmpdir, 'foobar-0.42.1'))
- @patch('pgxnclient.utils.zip.ZipArchive.unpack')
+ @patch('pgxnclient.zip.ZipArchive.unpack')
def test_install_local_zip(self, mock_unpack):
fn = get_test_filename('foobar-0.42.1.zip')
mock_unpack.side_effect = ZipArchive(fn).unpack_orig
@@ -458,7 +458,7 @@ def test_install_local_dir(self):
tdir = tempfile.mkdtemp()
try:
- from pgxnclient.utils.zip import unpack
+ from pgxnclient.zip import unpack
dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
from pgxnclient.cli import main
@@ -605,7 +605,7 @@ def test_check_psql_options(self, mock_get):
args = self.mock_popen.call_args[0][0]
self.assertEqual('somewhere', args[args.index('--host') + 1])
- @patch('pgxnclient.utils.zip.ZipArchive.unpack')
+ @patch('pgxnclient.zip.ZipArchive.unpack')
@patch('pgxnclient.api.get_file')
def test_load_local_zip(self, mock_get, mock_unpack):
mock_get.side_effect = lambda *args: self.fail('network invoked')
@@ -621,7 +621,7 @@ def test_load_local_zip(self, mock_get, mock_unpack):
self.assertEquals(communicate.call_args[0][0],
'CREATE EXTENSION foobar;')
- @patch('pgxnclient.utils.tar.TarArchive.unpack')
+ @patch('pgxnclient.tar.TarArchive.unpack')
@patch('pgxnclient.api.get_file')
def test_load_local_tar(self, mock_get, mock_unpack):
mock_get.side_effect = lambda *args: self.fail('network invoked')
@@ -643,7 +643,7 @@ def test_load_local_dir(self, mock_get):
tdir = tempfile.mkdtemp()
try:
- from pgxnclient.utils.zip import unpack
+ from pgxnclient.zip import unpack
dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
from pgxnclient.cli import main
@@ -661,7 +661,7 @@ def test_load_local_dir(self, mock_get):
def test_load_extensions_order(self):
tdir = tempfile.mkdtemp()
try:
- from pgxnclient.utils.zip import unpack
+ from pgxnclient.zip import unpack
dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
shutil.copyfile(
get_test_filename('META-manyext.json'),
@@ -688,7 +688,7 @@ def test_load_extensions_order(self):
def test_unload_extensions_order(self):
tdir = tempfile.mkdtemp()
try:
- from pgxnclient.utils.zip import unpack
+ from pgxnclient.zip import unpack
dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
shutil.copyfile(
get_test_filename('META-manyext.json'),
@@ -715,7 +715,7 @@ def test_unload_extensions_order(self):
def test_load_list(self):
tdir = tempfile.mkdtemp()
try:
- from pgxnclient.utils.zip import unpack
+ from pgxnclient.zip import unpack
dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
shutil.copyfile(
get_test_filename('META-manyext.json'),
@@ -738,7 +738,7 @@ def test_load_list(self):
def test_unload_list(self):
tdir = tempfile.mkdtemp()
try:
- from pgxnclient.utils.zip import unpack
+ from pgxnclient.zip import unpack
dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
shutil.copyfile(
get_test_filename('META-manyext.json'),
@@ -761,7 +761,7 @@ def test_unload_list(self):
def test_load_missing(self):
tdir = tempfile.mkdtemp()
try:
- from pgxnclient.utils.zip import unpack
+ from pgxnclient.zip import unpack
dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
shutil.copyfile(
get_test_filename('META-manyext.json'),
@@ -779,7 +779,7 @@ def test_load_missing(self):
def test_unload_missing(self):
tdir = tempfile.mkdtemp()
try:
- from pgxnclient.utils.zip import unpack
+ from pgxnclient.zip import unpack
dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
shutil.copyfile(
get_test_filename('META-manyext.json'),
View
@@ -16,7 +16,8 @@
from pgxnclient.archive import Archive
import logging
-logger = logging.getLogger('pgxnclient.utils.zip')
+logger = logging.getLogger('pgxnclient.zip')
+
class ZipArchive(Archive):
"""Handle .zip archives"""

0 comments on commit d778df6

Please sign in to comment.