def METHOD_NAME(self, _send_email):
    """ Check that user is blocked if rate limited too many times
    """
    self._set_user('contributor')
    self._create_document()
    self.session.refresh(self.user)
    for n in range(0, self.max_times + 1):
        self.assertFalse(self.user.blocked)
        self._wait()
        for i in range(0, self.limit):
            self._update_document()
            self.session.refresh(self.user)
            self.assertEqual(
                self.user.ratelimit_remaining, self.limit - 1 - i)
        self._update_document(status=429)
        self.session.refresh(self.user)
        self.assertEqual(self.user.ratelimit_times, n + 1)
    # User has reached their max number of allowed rate limited windows
    # thus is now blocked:
    self.assertTrue(self.user.blocked)
    self.assertEqual(self.user.ratelimit_times, self.max_times + 1)
    # Two emails have been set for each rate limited windows, and one
    # after the user has been blocked
    self.assertEqual(_send_email.call_count, 3)
    _send_email.assert_called_with(
        'fixme@camptocamp.org',
        subject="Un usage excessif de l'API a été détecté",
        body="Bonjour\n\nLe contributeur Contributor a atteint une "
             "nouvelle fois le nombre maximum autorisé de modifications "
             "via l'API camptocamp.org.\nIl a également dépassé le nombre "
             "maximum autorisé de blocages temporaires et a donc été "
             "définitivement bloqué.\nSon profil : "
             "http://localhost:6553/profiles/3")
    self._update_document(status=403)