def METHOD_NAME(app, test_users, login_user):
    headers = [('Content-Type', 'application/json'),
               ('Accept', 'application/json')]
    def assert_user_token_list(names, expected_code=200):
        req = client.get(url_for('b2share_users.user_token_list'),
                         headers=headers)
        assert req.status_code == expected_code
        if req.status_code == 200:
            hits = json.loads(req.get_data(as_text=True))['hits']
            assert hits['total'] == len(names)
            assert set([h['name'] for h in hits['hits']]) == set(names)
    def get_user_token(token_id, expected_code=200):
        url = url_for('b2share_users.user_token_item', token_id=token_id)
        req = client.get(url, headers=headers)
        assert req.status_code == expected_code
        return json.loads(req.get_data(as_text=True))
    def create_user_token_request(token_name):
        return client.post(url_for('b2share_users.user_token_list'),
                           data=json.dumps({'token_name':token_name}),
                           headers=headers)
    def create_user_token(token_name):
        req = create_user_token_request(token_name)
        assert req.status_code == 201
        token = json.loads(req.get_data(as_text=True))
        token_noaccess = get_user_token(token['id'])
        assert 'access_token' in token and 'access_token' not in token_noaccess
        assert token['id'] == token_noaccess['id']
        assert token['name'] == token_noaccess['name']
        return token
    def delete_user_token(token_id):
        url = url_for('b2share_users.user_token_item', token_id=token_id)
        req = client.delete(url, headers=headers)
        assert req.status_code == 200
        assert json.loads(req.get_data(as_text=True)) == {}
    with app.app_context():
        with app.test_client() as client:
            # test get tokens of anonymous user
            assert_user_token_list([], expected_code=401)
            assert_user_token_list([], expected_code=401)
            # test tokens for logged in user
            user = test_users['normal']
            login_user(user, client)
            assert_user_token_list([])
            # test bad token requests
            get_user_token(42, expected_code=404)
            bad_create_token_request = create_user_token_request(None)
            assert bad_create_token_request.status_code == 400
            # test create and list tokens
            token1 = create_user_token('test42')
            assert token1['name'] == 'test42'
            assert_user_token_list(['test42'])
            token2 = create_user_token('test42+1')
            assert token2['name'] == 'test42+1'
            assert_user_token_list(['test42', 'test42+1'])
            delete_user_token(token1['id'])
            assert_user_token_list(['test42+1'])
            delete_user_token(token2['id'])
            assert_user_token_list([])