diff --git a/src/service.py b/src/service.py index 666fba9a..f91bc4ab 100644 --- a/src/service.py +++ b/src/service.py @@ -466,8 +466,8 @@ def install(self) -> bool: if not super().install(): return False + logger.info("Creating a custom metrics file and configuring the DCGM snap to use it") try: - logger.info("Creating a custom metrics file and configuring the DCGM snap to use it") shutil.copy(self.metrics_file, self.snap_common) self.snap_client.set({self.metric_config: self.metric_config_value}) self.snap_client.restart(reload=True) diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py index 70416f2a..95c320e6 100644 --- a/tests/unit/test_service.py +++ b/tests/unit/test_service.py @@ -844,8 +844,8 @@ def test_install_failed(self): exporter_install_ok = self.exporter.install() - self.exporter.strategy.install.accept_called() - self.mock_shutil.copy.accept_not_called() + self.exporter.strategy.install.assert_called() + self.mock_shutil.copy.assert_not_called() self.assertFalse(exporter_install_ok) def test_install_success(self): @@ -853,14 +853,14 @@ def test_install_success(self): exporter_install_ok = self.exporter.install() - self.exporter.strategy.install.accept_called() - self.mock_shutil.copy.accept_called_with( + self.exporter.strategy.install.assert_called() + self.mock_shutil.copy.assert_called_with( self.exporter.metrics_file, self.exporter.snap_common ) - self.exporter.snap_client.set.accept_called_with( + self.exporter.snap_client.set.assert_called_with( {self.exporter.metric_config: self.exporter.metric_config_value} ) - self.exporter.snap_client.restart.accept_called_with(reload=True) + self.exporter.snap_client.restart.assert_called_with(reload=True) self.assertTrue(exporter_install_ok) def test_install_metrics_copy_fail(self): @@ -869,8 +869,8 @@ def test_install_metrics_copy_fail(self): exporter_install_ok = self.exporter.install() - self.exporter.strategy.install.accept_called() - self.exporter.snap_client.restart.accept_not_called() + self.exporter.strategy.install.assert_called() + self.exporter.snap_client.restart.assert_not_called() self.assertFalse(exporter_install_ok)