Skip to content

Commit

Permalink
Fixed traceback on error when a dir doesn't contain META.json
Browse files Browse the repository at this point in the history
Closes issue #19.
  • Loading branch information
dvarrazzo committed Nov 10, 2012
1 parent 69d8b22 commit af6597d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pgxnclient/commands/__init__.py
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions pgxnclient/tests/test_commands.py
Expand Up @@ -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')
Expand Down

0 comments on commit af6597d

Please sign in to comment.