Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-narozniak committed May 21, 2024
1 parent 74517cf commit de17b60
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions datasets/flwr_datasets/telemetry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class TelemetryTest(unittest.TestCase):
"""Tests for the telemetry module."""

@mock.patch("flwr_datasets.telemetry.FLWR_DATASETS_TELEMETRY_ENABLED", "1")
@mock.patch("flwr_datasets.telemetry.FLWR_TELEMETRY_ENABLED", "1")
def test_event(self) -> None:
"""Test if sending works against the actual API."""
# Prepare
Expand All @@ -39,7 +39,7 @@ def test_event(self) -> None:
# Assert
self.assertEqual(actual, expected)

@mock.patch("flwr_datasets.telemetry.FLWR_DATASETS_TELEMETRY_ENABLED", "1")
@mock.patch("flwr_datasets.telemetry.FLWR_TELEMETRY_ENABLED", "1")
def test_not_blocking(self) -> None:
"""Test if the code is blocking.
Expand All @@ -58,7 +58,7 @@ def test_not_blocking(self) -> None:
# Assert
self.assertLess(duration_actual, duration_max)

@mock.patch("flwr.common.telemetry.FLWR_TELEMETRY_ENABLED", "0")
@mock.patch("flwr_datasets.telemetry.FLWR_TELEMETRY_ENABLED", "0")
def test_telemetry_disabled(self) -> None:
"""Test opt-out."""
# Prepare
Expand Down Expand Up @@ -102,10 +102,14 @@ def _new_failing_get_home() -> None:

# Execute
with mock.patch(
"flwr.common.telemetry._get_home",
"flwr_datasets.telemetry._get_home",
new_callable=new_callable,
):
source_id = _get_source_id()

# Assert
self.assertEqual(source_id, except_value)


if __name__ == "__main__":
unittest.main()

0 comments on commit de17b60

Please sign in to comment.