<s> import socket <EOL> from grr . lib import flags <EOL> from grr . lib import ip_resolver <EOL> from grr . lib import rdfvalue <EOL> from grr . lib import test_lib <EOL> from grr . lib import utils <EOL> class IPResolverTest ( test_lib . GRRBaseTest ) : <EOL> def testIPInfo ( self ) : <EOL> args = [ ] <EOL> def MockGetNameInfo ( ip , unused_flags ) : <EOL> args . append ( ip ) <EOL> return "<STR_LIT>" , ip [ <NUM_LIT:1> ] <EOL> resolver = ip_resolver . IPResolver ( ) <EOL> with utils . Stubber ( socket , "<STR_LIT>" , MockGetNameInfo ) : <EOL> for ip , result in [ <EOL> ( "<STR_LIT>" , ip_resolver . IPInfo . UNKNOWN ) , <EOL> ( "<STR_LIT>" , ip_resolver . IPInfo . INTERNAL ) , <EOL> ( "<STR_LIT>" , ip_resolver . IPInfo . INTERNAL ) , <EOL> ( "<STR_LIT>" , ip_resolver . IPInfo . INTERNAL ) , <EOL> ( "<STR_LIT>" , ip_resolver . IPInfo . EXTERNAL ) , <EOL> ( "<STR_LIT>" , ip_resolver . IPInfo . EXTERNAL ) , <EOL> ] : <EOL> rdf_ip = rdfvalue . RDFString ( ip ) <EOL> info , _ = resolver . RetrieveIPInfo ( rdf_ip ) <EOL> self . assertEqual ( info , result ) <EOL> self . assertEqual ( len ( args ) , <NUM_LIT:1> ) <EOL> def main ( argv ) : <EOL> test_lib . main ( argv ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> flags . StartMain ( main ) </s>
