Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Rename mocks to match mocked function names.

Co-authored-by: Sébastien Morais <[email protected]>
  • Loading branch information
isaacwaldron and SMoraisAnsys authored Apr 26, 2024
1 parent 181db50 commit e74e5f1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/legacy/unit/test_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_create_padstack_instance(self):
"pyedb.dotnet.edb_core.dotnet.database.EdbDotNet.logger",
new_callable=PropertyMock,
)
def test_conflict_files_removal_success(self, mock_logger, mock_rmtree, mock_isfile):
def test_conflict_files_removal_success(self, mock_logger, mock_unlink, mock_isfile):
logger_mock = MagicMock()
mock_logger.return_value = logger_mock
mock_isfile.side_effect = lambda file: file.endswith((".aedt", ".aedt.lock"))
Expand All @@ -188,7 +188,7 @@ def test_conflict_files_removal_success(self, mock_logger, mock_rmtree, mock_isf
_ = Edb(edbpath, remove_existing_aedt=True)

for file in files:
mock_rmtree.assert_any_call(file)
mock_unlink.assert_any_call(file)
logger_mock.info.assert_any_call(f"Deleted AEDT project-related file {file}.")

@patch("os.path.isfile")
Expand All @@ -197,7 +197,7 @@ def test_conflict_files_removal_success(self, mock_logger, mock_rmtree, mock_isf
"pyedb.dotnet.edb_core.dotnet.database.EdbDotNet.logger",
new_callable=PropertyMock,
)
def test_conflict_files_removal_failure(self, mock_logger, mock_rmtree, mock_isfile):
def test_conflict_files_removal_failure(self, mock_logger, mock_unlink, mock_isfile):
logger_mock = MagicMock()
mock_logger.return_value = logger_mock
mock_isfile.side_effect = lambda file: file.endswith((".aedt", ".aedt.lock"))
Expand All @@ -209,7 +209,7 @@ def test_conflict_files_removal_failure(self, mock_logger, mock_rmtree, mock_isf
_ = Edb(edbpath, remove_existing_aedt=True)

for file in files:
mock_rmtree.assert_any_call(file)
mock_unlink.assert_any_call(file)
logger_mock.info.assert_any_call(f"Failed to delete AEDT project-related file {file}.")

@patch("os.path.isfile")
Expand All @@ -218,18 +218,18 @@ def test_conflict_files_removal_failure(self, mock_logger, mock_rmtree, mock_isf
"pyedb.dotnet.edb_core.dotnet.database.EdbDotNet.logger",
new_callable=PropertyMock,
)
def test_conflict_files_leave_in_place(self, mock_logger, mock_rmtree, mock_isfile):
def test_conflict_files_leave_in_place(self, mock_logger, mock_unlink, mock_isfile):
logger_mock = MagicMock()
mock_logger.return_value = logger_mock
mock_isfile.side_effect = lambda file: file.endswith((".aedt", ".aedt.lock"))
mock_rmtree.side_effect = Exception("Could not delete file")
mock_unlink.side_effect = Exception("Could not delete file")

edbpath = "file.edb"
aedt_file = os.path.splitext(edbpath)[0] + ".aedt"
files = [aedt_file, aedt_file + ".lock"]
_ = Edb(edbpath)

mock_rmtree.assert_not_called()
mock_unlink.assert_not_called()
for file in files:
logger_mock.warning.assert_any_call(
f"AEDT project-related file {file} exists and may need to be deleted before opening the EDB in HFSS 3D Layout." # noqa: E501
Expand Down

0 comments on commit e74e5f1

Please sign in to comment.