def test_authenticate_username_not_validated_by_manager(self):
    'Test to authenticate when not validated by manager.'
    self.user.validated_by_email = True
    self.user.validated_by_manager = False
    self.user.save()
    backend = DakaraModelBackend()
    with self.assertRaisesRegex(ValidationError, 'This user account has not been validated by a manager'):
        backend.authenticate(MagicMock(), username='TestUser', password='pass')
Test to authenticate when not validated by manager.
def test_authenticate_username_not_validated_by_manager(self):
    
    self.user.validated_by_email = True
    self.user.validated_by_manager = False
    self.user.save()
    backend = DakaraModelBackend()
    with self.assertRaisesRegex(ValidationError, 'This user account has not been validated by a manager'):
        backend.authenticate(MagicMock(), username='TestUser', password='pass')