VMware: Remove tests for None in fake._db_content['files']
This looks like a legacy. _db_content['files'] is always initialised, and checking it for None distracts from what is actually being tested. This was also the only use of NoFilesFound, so we remove it entirely. Change-Id: Ided6c71b68a654476512016ddf886e895d75e571
This commit is contained in:
@@ -1081,10 +1081,6 @@ class FileNotFound(NotFound):
|
||||
msg_fmt = _("File %(file_path)s could not be found.")
|
||||
|
||||
|
||||
class NoFilesFound(NotFound):
|
||||
msg_fmt = _("Zero files could be found.")
|
||||
|
||||
|
||||
class SwitchNotFoundForNetworkAdapter(NotFound):
|
||||
msg_fmt = _("Virtual switch associated with the "
|
||||
"network adapter %(adapter)s not found.")
|
||||
|
||||
@@ -962,8 +962,6 @@ def _add_file(file_path):
|
||||
|
||||
def _remove_file(file_path):
|
||||
"""Removes a file reference from the db."""
|
||||
if _db_content.get("files") is None:
|
||||
raise exception.NoFilesFound()
|
||||
# Check if the remove is for a single file object or for a folder
|
||||
if file_path.find(".vmdk") != -1:
|
||||
if file_path not in _db_content.get("files"):
|
||||
@@ -991,8 +989,6 @@ def fake_get_network(*args, **kwargs):
|
||||
|
||||
def get_file(file_path):
|
||||
"""Check if file exists in the db."""
|
||||
if _db_content.get("files") is None:
|
||||
raise exception.NoFilesFound()
|
||||
return file_path in _db_content.get("files")
|
||||
|
||||
|
||||
@@ -1308,8 +1304,6 @@ class FakeVim(object):
|
||||
"""Searches the datastore for a file."""
|
||||
# TODO(garyk): add support for spec parameter
|
||||
ds_path = kwargs.get("datastorePath")
|
||||
if _db_content.get("files", None) is None:
|
||||
raise exception.NoFilesFound()
|
||||
matched_files = set()
|
||||
# Check if we are searching for a file or a directory
|
||||
directory = False
|
||||
@@ -1373,8 +1367,6 @@ class FakeVim(object):
|
||||
def _make_dir(self, method, *args, **kwargs):
|
||||
"""Creates a directory in the datastore."""
|
||||
ds_path = kwargs.get("name")
|
||||
if _db_content.get("files", None) is None:
|
||||
raise exception.NoFilesFound()
|
||||
if get_file(ds_path):
|
||||
raise vexc.FileAlreadyExistsException()
|
||||
_db_content["files"].append('%s/' % ds_path)
|
||||
|
||||
Reference in New Issue
Block a user