Skip to content

Commit

Permalink
updated testcase file
Browse files Browse the repository at this point in the history
  • Loading branch information
kanza-latif committed Nov 1, 2024
1 parent e401f15 commit 6bd1caf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/memory_statistics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ def test_memory_statistics_retention_period(mock_db):
)


def test_memory_statistics_retention_period_exception(mock_db):
"""Test setting retention period for Memory Statistics when an exception occurs."""
mock_db.get_table.return_value = {"memory_statistics": {}}
runner = CliRunner()
retention_period_value = 30

# Mock `mod_entry` to raise an exception.
mock_db.mod_entry.side_effect = Exception("Simulated retention period error")

with patch("click.echo") as mock_echo:
result = runner.invoke(memory_statistics_retention_period, [str(retention_period_value)])
assert result.exit_code == 0 # Ensure the command exits without crashing.

# Check that the error message was outputted.
mock_echo.assert_any_call("Error setting retention period: Simulated retention period error", err=True)


def test_memory_statistics_sampling_interval(mock_db):
"""Test setting the sampling interval for Memory Statistics."""
mock_db.get_table.return_value = {"memory_statistics": {}}
Expand Down

0 comments on commit 6bd1caf

Please sign in to comment.