<s> from bottom . pack import pack_command <EOL> import pytest <EOL> import re <EOL> SPACES = re . compile ( r"<STR_LIT>" ) <EOL> def like ( pattern , value ) : <EOL> """<STR_LIT>""" <EOL> pattern = re . escape ( pattern ) <EOL> index = pattern . rfind ( '<STR_LIT::>' ) <EOL> if index >= <NUM_LIT:0> : <EOL> pattern = SPACES . sub ( r'<STR_LIT>' , pattern [ : index ] ) + pattern [ index : ] <EOL> else : <EOL> pattern = SPACES . sub ( r'<STR_LIT>' , pattern ) <EOL> pattern += r"<STR_LIT>" <EOL> return bool ( re . match ( pattern , value ) ) <EOL> def test_no_command ( ) : <EOL> """<STR_LIT>""" <EOL> with pytest . raises ( ValueError ) : <EOL> pack_command ( None ) <EOL> with pytest . raises ( ValueError ) : <EOL> pack_command ( "<STR_LIT>" ) <EOL> def test_bad_command ( ) : <EOL> """<STR_LIT>""" <EOL> with pytest . raises ( ValueError ) : <EOL> pack_command ( object ( ) ) <EOL> def test_unknown_command ( ) : <EOL> """<STR_LIT>""" <EOL> with pytest . raises ( ValueError ) : <EOL> pack_command ( "<STR_LIT>" , param = "<STR_LIT:foo>" ) <EOL> def test_ignore_case ( ) : <EOL> """<STR_LIT>""" <EOL> assert "<STR_LIT>" == pack_command ( "<STR_LIT>" , password = "<STR_LIT:foo>" ) <EOL> def test_pass ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , password = "<STR_LIT:foo>" ) ) <EOL> def test_nick ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , nick = "<STR_LIT:foo>" ) ) <EOL> def test_user ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , user = "<STR_LIT:user>" , <EOL> realname = "<STR_LIT>" , mode = <NUM_LIT:1> ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , user = "<STR_LIT:user>" , <EOL> realname = "<STR_LIT>" ) ) <EOL> def test_oper ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , user = "<STR_LIT:user>" , <EOL> password = "<STR_LIT>" ) ) <EOL> def test_usermode ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , <EOL> nick = "<STR_LIT>" , modes = "<STR_LIT>" ) ) <EOL> def test_service ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = "<STR_LIT>" , distribution = "<STR_LIT>" , <EOL> type = "<STR_LIT:type>" , info = "<STR_LIT:info>" ) ) <EOL> def test_quit ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , message = "<STR_LIT:message>" ) ) <EOL> def test_squit ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , server = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , server = "<STR_LIT>" , <EOL> message = "<STR_LIT>" ) ) <EOL> def test_join ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = <NUM_LIT:0> ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = "<STR_LIT>" , <EOL> key = "<STR_LIT:key>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , <EOL> channel = [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> key = [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> def test_part ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = "<STR_LIT>" , <EOL> message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , <EOL> channel = [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> message = "<STR_LIT>" ) ) <EOL> def test_channelmode ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = "<STR_LIT>" , modes = "<STR_LIT>" , params = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = "<STR_LIT>" , modes = "<STR_LIT>" , params = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = "<STR_LIT>" , modes = "<STR_LIT>" ) ) <EOL> def test_topic ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = "<STR_LIT>" , <EOL> message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = "<STR_LIT>" ) ) <EOL> def test_names ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , <EOL> channel = [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_list ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , channel = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_invite ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , nick = "<STR_LIT>" , <EOL> channel = "<STR_LIT>" ) ) <EOL> def test_command ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = "<STR_LIT>" , nick = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = "<STR_LIT>" , nick = "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = "<STR_LIT>" , nick = [ "<STR_LIT>" , "<STR_LIT>" ] , message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , channel = [ "<STR_LIT>" , "<STR_LIT>" ] , nick = [ "<STR_LIT>" , "<STR_LIT>" ] , message = "<STR_LIT>" ) ) <EOL> def test_privmsg ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , target = "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , target = "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> def test_notice ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , target = "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , target = "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> def test_motd ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_lusers ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , mask = "<STR_LIT>" ) ) <EOL> def test_version ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_stats ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , query = "<STR_LIT:m>" ) ) <EOL> def test_links ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , remote = "<STR_LIT>" , <EOL> mask = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , mask = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> with pytest . raises ( KeyError ) : <EOL> pack_command ( "<STR_LIT>" , remote = "<STR_LIT>" ) <EOL> def test_time ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_connect ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , target = "<STR_LIT>" , port = <NUM_LIT> , remote = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , target = "<STR_LIT>" , port = <NUM_LIT> ) ) <EOL> def test_trace ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_admin ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_info ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_servlist ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , <EOL> mask = "<STR_LIT>" , type = <NUM_LIT:3> ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , mask = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_squery ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , target = "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> def test_who ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , mask = "<STR_LIT>" , o = True ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , mask = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_whois ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , mask = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , mask = "<STR_LIT>" ) ) <EOL> def test_whowas ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , nick = "<STR_LIT>" , count = <NUM_LIT:9> ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , nick = "<STR_LIT>" ) ) <EOL> def test_kill ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> def test_ping ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_pong ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_away ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_rehash ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_die ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_restart ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_summon ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = "<STR_LIT>" , target = "<STR_LIT>" , channel = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = "<STR_LIT>" , target = "<STR_LIT>" ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = "<STR_LIT>" ) ) <EOL> def test_users ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" ) ) <EOL> def test_wallops ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( "<STR_LIT>" , message = "<STR_LIT>" ) ) <EOL> def test_userhost ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = "<STR_LIT>" ) ) <EOL> def test_ison ( ) : <EOL> """<STR_LIT>""" <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> assert like ( "<STR_LIT>" , pack_command ( <EOL> "<STR_LIT>" , nick = "<STR_LIT>" ) ) </s>
