def test_main_confirm_dir_check_unshifted(self, mock_parser_class, mock_confirm_dir, mock_shift_dir): mock_parser = mock.MagicMock() mock_parser.parse_args.return_value = mock_parser mock_parser.idempotent = False mock_parser.confirm = True mock_parser.exit_on_fail = True mock_parser.path = '/test/path' mock_parser.uid = self.uid_maps mock_parser.gid = self.gid_maps mock_parser.nobody = main.NOBODY_ID mock_parser.dry_run = False mock_parser.verbose = False mock_parser_class.return_value = mock_parser mock_confirm_dir.return_value = True try: main.main() except SystemExit as sys_exit: self.assertEqual(sys_exit.code, 0) mock_confirm_dir_call = mock.call('/test/path', self.uid_maps, self.gid_maps, main.NOBODY_ID) mock_confirm_dir.assert_has_calls([mock_confirm_dir_call]) mock_shift_dir.assert_has_calls([])
def test_main_confirm_dir_idempotent_unshifted(self, mock_parser_class, mock_confirm_dir, mock_shift_dir): mock_parser = mock.MagicMock() mock_parser.parse_args.return_value = mock_parser mock_parser.idempotent = True mock_parser.confirm = False mock_parser.path = '/test/path' mock_parser.uid = self.uid_maps mock_parser.gid = self.gid_maps mock_parser.nobody = main.NOBODY_ID mock_parser.dry_run = False mock_parser.verbose = False mock_parser_class.return_value = mock_parser mock_confirm_dir.return_value = False main.main() mock_confirm_dir_call = mock.call('/test/path', self.uid_maps, self.gid_maps, main.NOBODY_ID) mock_confirm_dir.assert_has_calls([mock_confirm_dir_call]) mock_shift_dir_call = mock.call('/test/path', self.uid_maps, self.gid_maps, main.NOBODY_ID, dry_run=False, verbose=False) mock_shift_dir.assert_has_calls([mock_shift_dir_call])