code: def mock_django_connection(disabled_features=None):
      
      db = connections.databases['default']
      db['PASSWORD'] = '****'
      db['USER'] = '**Database disabled for unit tests**'
      ConnectionHandler.__getitem__ = MagicMock(name='mock_connection')
      # noinspection PyUnresolvedReferences
      mock_connection = ConnectionHandler.__getitem__.return_value
      if disabled_features:
          for feature in disabled_features:
              setattr(mock_connection.features, feature, False)
      mock_ops = mock_connection.ops
  
      # noinspection PyUnusedLocal
      def compiler(queryset, connection, using, **kwargs):
          result = MagicMock(name='mock_connection.ops.compiler()')
          # noinspection PyProtectedMember
          result.execute_sql.side_effect = NotSupportedError(
              "Mock database tried to execute SQL for {} model.".format(
                  queryset.model._meta.object_name))
          result.has_results.side_effect = result.execute_sql.side_effect
          return result
  
      mock_ops.compiler.return_value.side_effect = compiler
      mock_ops.integer_field_range.return_value = (-sys.maxsize - 1, sys.maxsize)
      mock_ops.max_name_length.return_value = sys.maxsize
  
      Model.refresh_from_db = Mock()
docs: Overwrite the Django database configuration with a mocked version.
  
      This is a helper function that does the actual monkey patching.