From a200f2674ebf665da6e2925cc26dc5fa02dd0f7d Mon Sep 17 00:00:00 2001 From: Joseph Wyman Date: Sat, 16 Nov 2024 12:10:18 -0500 Subject: [PATCH] add tests for metric of no change --- .../test_privacy_metrics_service.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/backend/src/tests/service_tests/test_privacy_metrics_service.py b/backend/src/tests/service_tests/test_privacy_metrics_service.py index 7ee163f2..4765cf27 100644 --- a/backend/src/tests/service_tests/test_privacy_metrics_service.py +++ b/backend/src/tests/service_tests/test_privacy_metrics_service.py @@ -262,3 +262,30 @@ def test_ratio_threshold(self): assert point_one_btc_threshold == 5 assert point_zero_one_btc_threshold == 10 assert point_zero_zero_one_btc_threshold == 10 + + # TODO tests for analyze_minimal_tx_history_reveal + + def test_analyze_no_change_pass(self): + mock_transaction_model = MagicMock() + mock_transaction_model.sent_amount = 1000000000 + mock_transaction_model.received_amount = 0 + response = PrivacyMetricsService.analyze_no_change( + mock_transaction_model) + assert response is True + + # is a user received but didn't send then the amount + # they received is not change, therefore no change passes + mock_transaction_model = MagicMock() + mock_transaction_model.sent_amount = 0 + mock_transaction_model.received_amount = 100000000 + response = PrivacyMetricsService.analyze_no_change( + mock_transaction_model) + assert response is True + + def test_analyze_no_change_fail(self): + mock_transaction_model = MagicMock() + mock_transaction_model.sent_amount = 1000000000 + mock_transaction_model.received_amount = 10 + response = PrivacyMetricsService.analyze_no_change( + mock_transaction_model) + assert response is False