<s> import pytest <EOL> import sys <EOL> import time <EOL> from . test_base_class import TestBaseClass <EOL> from aerospike import exception as e <EOL> aerospike = pytest . importorskip ( "<STR_LIT>" ) <EOL> try : <EOL> import aerospike <EOL> except : <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> class TestQueryUser ( TestBaseClass ) : <EOL> pytestmark = pytest . mark . skipif ( <EOL> TestBaseClass ( ) . get_hosts ( ) [ <NUM_LIT:1> ] == None , <EOL> reason = "<STR_LIT>" ) <EOL> def setup_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> hostlist , user , password = TestBaseClass ( ) . get_hosts ( ) <EOL> config = { "<STR_LIT>" : hostlist } <EOL> TestQueryUser . Me = self <EOL> self . client = aerospike . client ( config ) . connect ( user , password ) <EOL> try : <EOL> self . client . admin_drop_user ( "<STR_LIT>" ) <EOL> except : <EOL> pass <EOL> policy = { } <EOL> user = "<STR_LIT>" <EOL> password = "<STR_LIT>" <EOL> roles = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . client . admin_create_user ( user , password , roles , policy ) <EOL> self . delete_users = [ ] <EOL> def teardown_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> self . client . admin_drop_user ( "<STR_LIT>" , policy ) <EOL> self . client . close ( ) <EOL> def test_query_user_without_any_parameters ( self ) : <EOL> with pytest . raises ( TypeError ) as typeError : <EOL> self . client . admin_query_user ( ) <EOL> assert "<STR_LIT>" in str ( <EOL> typeError . value ) <EOL> def test_query_user_with_proper_parameters ( self ) : <EOL> user = "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> user_details = self . client . admin_query_user ( user ) <EOL> assert user_details == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def test_query_user_with_invalid_timeout_policy_value ( self ) : <EOL> policy = { "<STR_LIT>" : <NUM_LIT:0.1> } <EOL> user = "<STR_LIT>" <EOL> try : <EOL> self . client . admin_query_user ( user , policy ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_query_user_with_proper_timeout_policy_value ( self ) : <EOL> policy = { '<STR_LIT>' : <NUM_LIT:30> } <EOL> user = "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> user_details = self . client . admin_query_user ( user , policy ) <EOL> assert user_details == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def test_query_user_with_none_username ( self ) : <EOL> policy = { '<STR_LIT>' : <NUM_LIT:30> } <EOL> user = None <EOL> try : <EOL> self . client . admin_query_user ( user , policy ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_query_user_with_empty_username ( self ) : <EOL> policy = { } <EOL> user = "<STR_LIT>" <EOL> try : <EOL> self . client . admin_query_user ( user , policy ) <EOL> except e . InvalidUser as exception : <EOL> assert exception . code == <NUM_LIT> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_query_user_with_nonexistent_username ( self ) : <EOL> policy = { } <EOL> user = "<STR_LIT>" <EOL> try : <EOL> self . client . admin_query_user ( user , policy ) <EOL> except e . InvalidUser as exception : <EOL> assert exception . code == <NUM_LIT> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_query_user_with_no_roles ( self ) : <EOL> policy = { } <EOL> user = "<STR_LIT>" <EOL> roles = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> status = self . client . admin_revoke_roles ( user , roles , policy ) <EOL> assert status == <NUM_LIT:0> <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> user_details = self . client . admin_query_user ( user ) <EOL> assert user_details == [ ] <EOL> def test_query_user_with_extra_argument ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { '<STR_LIT>' : <NUM_LIT:1000> } <EOL> with pytest . raises ( TypeError ) as typeError : <EOL> self . client . admin_query_user ( "<STR_LIT:foo>" , policy , "<STR_LIT>" ) <EOL> assert "<STR_LIT>" in str ( <EOL> typeError . value ) <EOL> def test_query_user_with_policy_as_string ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = "<STR_LIT>" <EOL> try : <EOL> self . client . admin_query_user ( "<STR_LIT:foo>" , policy ) <EOL> except e . AerospikeError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" </s>
