Coverage for website/registrations/tests/test_management.py: 100.00%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2025-08-14 10:31 +0000

1from unittest import mock 

2from unittest.mock import MagicMock 

3 

4from django.test import TestCase 

5 

6from registrations.management.commands.minimiseregistrations import Command 

7 

8 

9class ManagementMinimiseTest(TestCase): 

10 def test_add_argument(self): 

11 mock_parser = MagicMock() 

12 Command().add_arguments(mock_parser) 

13 mock_parser.add_argument.assert_called_with( 

14 "--dry-run", 

15 action="store_true", 

16 default=False, 

17 dest="dry-run", 

18 help="Dry run instead of saving data", 

19 ) 

20 

21 @mock.patch("registrations.services.execute_data_minimisation") 

22 def test_handle(self, execute_data_minimisation): 

23 Command().handle({}, **{"dry-run": False}) 

24 execute_data_minimisation.assert_called_with(False) 

25 Command().handle({}, **{"dry-run": True}) 

26 execute_data_minimisation.assert_called_with(True)