

def test_basic_metadata(standard_graph, session, users, groups, permissions):
    ' Test basic metadata functionality. '
    graph = standard_graph
    user_id = users['zorkian@a.co'].id
    assert (len(users['zorkian@a.co'].my_metadata()) == 0), 'No metadata yet'
    set_user_metadata(session, user_id, 'foo', 1)
    md = get_user_metadata(session, user_id)
    assert (len(md) == 1), 'One metadata item'
    assert ([d.data_value for d in md if (d.data_key == 'foo')] == ['1']), 'foo is 1'
    set_user_metadata(session, user_id, 'bar', 'test string')
    md = get_user_metadata(session, user_id)
    assert (len(md) == 2), 'Two metadata items'
    assert ([d.data_value for d in md if (d.data_key == 'bar')] == ['test string']), 'bar is test string'
    set_user_metadata(session, user_id, 'foo', 'test2')
    md = get_user_metadata(session, user_id)
    assert (len(md) == 2), 'Two metadata items'
    assert ([d.data_value for d in md if (d.data_key == 'foo')] == ['test2']), 'foo is test2'
    set_user_metadata(session, user_id, 'foo', None)
    md = get_user_metadata(session, user_id)
    assert (len(md) == 1), 'One metadata item'
    assert ([d.data_value for d in md if (d.data_key == 'foo')] == []), 'foo is not found'
    set_user_metadata(session, standard_graph, 'baz', None)
    md = get_user_metadata(session, user_id)
    assert (len(md) == 1), 'One metadata item'

dataset/ETHPy150Open dropbox/grouper/tests/test_users.py test_basic_metadata/VarMisuse@291/461 `user_id`->`standard_graph`