From fc99a9a35eef578ee16e17bcf00d9e29987dad3f Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 4 Nov 2022 15:32:45 +0100 Subject: [PATCH] OP-3426 - raise better exception if mongorestore not found --- tests/lib/db_handler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/lib/db_handler.py b/tests/lib/db_handler.py index ef3c2b52f6..82e741cc3b 100644 --- a/tests/lib/db_handler.py +++ b/tests/lib/db_handler.py @@ -118,7 +118,7 @@ class DBHandler: "Run with overwrite=True") else: if collection: - if collection in self.client[db_name_out].list_collection_names(): + if collection in self.client[db_name_out].list_collection_names(): # noqa self.client[db_name_out][collection].drop() else: self.teardown(db_name_out) @@ -132,7 +132,11 @@ class DBHandler: db_name=db_name, db_name_out=db_name_out, collection=collection) print("mongorestore query:: {}".format(query)) - subprocess.run(query) + try: + subprocess.run(query) + except FileNotFoundError: + raise RuntimeError("'mongorestore' utility must be on path." + "Please install it.") def teardown(self, db_name): """Drops 'db_name' if exists."""