Permalink
Browse files

Added tar download test

  • Loading branch information...
1 parent 8d18b1c commit 64d55c89b1cf6163d8e539c4e02923ed175b0833 @dvarrazzo committed Sep 5, 2012
Showing with 19 additions and 1 deletion.
  1. +18 −1 pgxnclient/tests/test_commands.py
  2. +1 −0 testdata/http%3A%2F%2Fexample.org%2Ffoobar-0.42.1.tar.gz
@@ -692,7 +692,7 @@ def test_load_local_dir(self, mock_get):
@patch('pgxnclient.zip.ZipArchive.unpack')
@patch('pgxnclient.network.get_file')
- def test_load_url(self, mock_get, mock_unpack):
+ def test_load_zip_url(self, mock_get, mock_unpack):
mock_get.side_effect = fake_get_file
mock_unpack.side_effect = ZipArchive.unpack_orig
@@ -707,6 +707,23 @@ def test_load_url(self, mock_get, mock_unpack):
self.assertEquals(communicate.call_args[0][0],
'CREATE EXTENSION foobar;')
+ @patch('pgxnclient.tar.TarArchive.unpack')
+ @patch('pgxnclient.network.get_file')
+ def test_load_tar_url(self, mock_get, mock_unpack):
+ mock_get.side_effect = fake_get_file
+ mock_unpack.side_effect = TarArchive.unpack_orig
+
+ from pgxnclient.cli import main
+ main(['load', '--yes',
+ 'http://example.org/foobar-0.42.1.tar.gz'])
+
+ self.assertEquals(mock_unpack.call_count, 0)
+ self.assertEquals(self.mock_popen.call_count, 1)
+ self.assert_('psql' in self.mock_popen.call_args[0][0][0])
+ communicate = self.mock_popen.return_value.communicate
+ self.assertEquals(communicate.call_args[0][0],
+ 'CREATE EXTENSION foobar;')
+
def test_load_extensions_order(self):
tdir = tempfile.mkdtemp()
try:

0 comments on commit 64d55c8

Please sign in to comment.