Skip to content

Commit

Permalink
Fix error message format from get_pdb_code()
Browse files Browse the repository at this point in the history
If the given PDB code does not exist, the error
reported was previously incorrectly formatted.
Fix and test for the right wording.
  • Loading branch information
benmwebb committed Sep 27, 2021
1 parent d840feb commit 27b8360
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions python/saliweb/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ def get_pdb_code(code, outdir):
in_pdb, out_pdb = _get_pdb_paths(code)
if not os.path.exists(in_pdb):
raise InputValidationError(
"PDB code '%s' does not exist in our copy of the PDB database.",
code)
"PDB code '%s' does not exist in our copy of the PDB database."
% code)
out_pdb = os.path.join(outdir, out_pdb)
fh_in = gzip.open(in_pdb, 'rb')
with open(out_pdb, 'wb') as fh_out:
Expand Down
7 changes: 5 additions & 2 deletions test/pyfrontend/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,11 @@ def __init__(self, tmpdir):
flask.current_app = MockApp(tmpdir)
self.assertRaises(saliweb.frontend.InputValidationError,
saliweb.frontend.get_pdb_code, "1@bc", tmpdir)
self.assertRaises(saliweb.frontend.InputValidationError,
saliweb.frontend.get_pdb_code, "1aaaaaa", tmpdir)
with self.assertRaises(saliweb.frontend.InputValidationError) as cm:
saliweb.frontend.get_pdb_code("1aaaaaa", tmpdir)
self.assertEqual(str(cm.exception),
"PDB code '1aaaaaa' does not exist in our copy "
"of the PDB database.")
self.assertFalse(saliweb.frontend.pdb_code_exists('1aaaaaa'))
self.assertTrue(saliweb.frontend.pdb_code_exists('1xyz'))
p = saliweb.frontend.get_pdb_code('1xyz', tmpdir)
Expand Down

0 comments on commit 27b8360

Please sign in to comment.