Permalink
Browse files

Fixed traceback on error when a dir doesn't contain META.json

Closes issue #19.
  • Loading branch information...
1 parent 69d8b22 commit af6597dd76acf65b402530cf90d8368745133c37 @dvarrazzo committed Nov 10, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 pgxnclient/commands/__init__.py
  2. +14 −0 pgxnclient/tests/test_commands.py
@@ -384,7 +384,7 @@ def get_meta(self, spec):
logger.debug("reading %s", fn)
if not os.path.exists(fn):
raise PgxnClientException(
- _("file 'META.json' not found in '%s'") % dir)
+ _("file 'META.json' not found in '%s'") % spec.dirname)
with open(fn) as f:
return load_json(f)
@@ -872,6 +872,20 @@ def test_unload_missing(self):
self.assertEquals(self.mock_popen.call_count, 0)
+ def test_missing_meta_dir(self):
+ # issue #19
+ tdir = tempfile.mkdtemp()
+ try:
+ from pgxnclient.zip import unpack
+ dir = unpack(get_test_filename('foobar-0.42.1.zip'), tdir)
+ os.unlink(os.path.join(dir, 'META.json'))
+
+ from pgxnclient.cli import main
+ self.assertRaises(PgxnClientException, main, ['load', dir])
+
+ finally:
+ shutil.rmtree(tdir)
+
class SearchTestCase(unittest.TestCase):
@patch('sys.stdout')

0 comments on commit af6597d

Please sign in to comment.