Exemplo n.º 1
0
def search():
    opts = get_opts('search_user', 'Searches for Users in a muam',
                    {'search_text': 'search_text'})

    session = get_session(opts)
    if not session:
        sys.exit('Invalid username/password.')

    success, resp_list = User.search(session, opts.search_text)

    if success:
        for resp in resp_list:
            print('{} - {}'.format(resp.get_ids(), resp.full_name))
    else:
        print('Search failed with code {} and message: {}'.format(
            resp.status_code, resp.text))
Exemplo n.º 2
0
def test_user_search():
    """--> tests search """
    
    success, resp_list = User.search(TEST_SESSION, '')
    if not success: log_response_error(resp_list)
    assert success
    LOGGER.debug('search result: {}'.format(str(resp_list)))
    assert len(resp_list) == 1
    resp = resp_list[0]
    assert resp.username == 'testing'
    assert resp.email == '*****@*****.**'
    assert resp.first_name == 'Tester'
    assert resp.full_name == 'Tester, Unit X'
    assert resp.last_name == 'Unit'
    assert resp.phone == '+1 (919) 999-9999'
    assert resp.profiles == {"muam": {"test": "value"}}
    assert resp.create_users == False
    assert resp.create_groups == True
    assert resp.grant_privs == False