<s> """<STR_LIT>""" <EOL> from twisted . trial . unittest import TestCase <EOL> from twisted . python . usage import UsageError <EOL> from twisted . names . tap import Options , _buildResolvers <EOL> from twisted . names . dns import PORT <EOL> from twisted . names . secondary import SecondaryAuthorityService <EOL> from twisted . names . resolve import ResolverChain <EOL> from twisted . names . client import Resolver <EOL> class OptionsTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_malformedSecondary ( self ) : <EOL> """<STR_LIT>""" <EOL> options = Options ( ) <EOL> self . assertRaises ( <EOL> UsageError , options . parseOptions , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertRaises ( <EOL> UsageError , options . parseOptions , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertRaises ( <EOL> UsageError , options . parseOptions , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertRaises ( <EOL> UsageError , options . parseOptions , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def test_secondary ( self ) : <EOL> """<STR_LIT>""" <EOL> options = Options ( ) <EOL> options . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( <EOL> [ ( ( '<STR_LIT>' , PORT ) , [ '<STR_LIT>' ] ) ] , options . secondaries ) <EOL> def test_secondaryExplicitPort ( self ) : <EOL> """<STR_LIT>""" <EOL> options = Options ( ) <EOL> options . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( <EOL> [ ( ( '<STR_LIT>' , <NUM_LIT> ) , [ '<STR_LIT>' ] ) ] , options . secondaries ) <EOL> def test_secondaryAuthorityServices ( self ) : <EOL> """<STR_LIT>""" <EOL> options = Options ( ) <EOL> options . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( len ( options . svcs ) , <NUM_LIT:2> ) <EOL> secondary = options . svcs [ <NUM_LIT:0> ] <EOL> self . assertIsInstance ( options . svcs [ <NUM_LIT:0> ] , SecondaryAuthorityService ) <EOL> self . assertEqual ( secondary . primary , '<STR_LIT>' ) <EOL> self . assertEqual ( secondary . _port , <NUM_LIT> ) <EOL> secondary = options . svcs [ <NUM_LIT:1> ] <EOL> self . assertIsInstance ( options . svcs [ <NUM_LIT:1> ] , SecondaryAuthorityService ) <EOL> self . assertEqual ( secondary . primary , '<STR_LIT>' ) <EOL> self . assertEqual ( secondary . _port , <NUM_LIT> ) <EOL> def test_recursiveConfiguration ( self ) : <EOL> """<STR_LIT>""" <EOL> options = Options ( ) <EOL> options . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> ca , cl = _buildResolvers ( options ) <EOL> for x in cl : <EOL> if isinstance ( x , ResolverChain ) : <EOL> recurser = x . resolvers [ - <NUM_LIT:1> ] <EOL> if isinstance ( recurser , Resolver ) : <EOL> recurser . _parseCall . cancel ( ) <EOL> self . assertIsInstance ( cl [ - <NUM_LIT:1> ] , ResolverChain ) </s>
