<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import sys <EOL> from salt . ext . six . moves import map <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> ) : <EOL> import unittest2 as unittest <EOL> else : <EOL> import unittest <EOL> import os <EOL> import stat <EOL> import time <EOL> import tempfile <EOL> import shutil <EOL> from ioflo . aid . odicting import odict <EOL> from ioflo . aid . timing import Timer , StoreTimer <EOL> from ioflo . base import storing <EOL> from ioflo . base . consoling import getConsole <EOL> console = getConsole ( ) <EOL> from raet import raeting <EOL> from salt . daemons import parse_hostname , extract_masters <EOL> def setUpModule ( ) : <EOL> console . reinit ( verbosity = console . Wordage . concise ) <EOL> def tearDownModule ( ) : <EOL> pass <EOL> class BasicTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . store = storing . Store ( stamp = <NUM_LIT:0.0> ) <EOL> self . timer = StoreTimer ( store = self . store , duration = <NUM_LIT:1.0> ) <EOL> self . port = <NUM_LIT> <EOL> self . opts = dict ( master_port = self . port ) <EOL> def tearDown ( self ) : <EOL> pass <EOL> def testParseHostname ( self ) : <EOL> '''<STR_LIT>''' <EOL> console . terse ( "<STR_LIT>" . format ( self . testParseHostname . __doc__ ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT:localhost>' , self . port ) , <EOL> ( '<STR_LIT:localhost>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT:127.0.0.1>' , self . port ) , <EOL> ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( <EOL> '<STR_LIT>' , <EOL> self . port ) , <EOL> ( '<STR_LIT>' , <EOL> <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT:localhost>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( <EOL> '<STR_LIT>' , <EOL> self . port ) , <EOL> ( '<STR_LIT>' , <EOL> <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT:localhost>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( <EOL> '<STR_LIT>' , <EOL> self . port ) , <EOL> ( '<STR_LIT>' , <EOL> <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT:localhost>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( <EOL> '<STR_LIT>' , <EOL> self . port ) , <EOL> ( '<STR_LIT>' , <EOL> <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , None ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , None ) <EOL> self . assertEquals ( parse_hostname ( list ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) , self . port ) , None ) <EOL> self . assertEquals ( parse_hostname ( list ( ) , self . port ) , None ) <EOL> self . assertEquals ( parse_hostname ( dict ( a = <NUM_LIT:1> ) , self . port ) , None ) <EOL> self . assertEquals ( parse_hostname ( dict ( ) , self . port ) , None ) <EOL> self . assertEquals ( parse_hostname ( <NUM_LIT> , self . port ) , None ) <EOL> self . assertEquals ( parse_hostname ( ( '<STR_LIT:localhost>' , <NUM_LIT> ) , self . port ) , None ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT:localhost>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( <EOL> '<STR_LIT>' , <EOL> self . port ) , <EOL> ( '<STR_LIT>' , <EOL> <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEquals ( parse_hostname ( '<STR_LIT>' , self . port ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> def testExtractMastersSingle ( self ) : <EOL> '''<STR_LIT>''' <EOL> console . terse ( "<STR_LIT>" . format ( self . testExtractMastersSingle . __doc__ ) ) <EOL> master = '<STR_LIT:localhost>' <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT:localhost>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = '<STR_LIT:127.0.0.1>' <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = '<STR_LIT>' <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT:localhost>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = '<STR_LIT>' <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = '<STR_LIT>' <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = '<STR_LIT>' <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = '<STR_LIT>' <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = '<STR_LIT>' <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = dict ( external = '<STR_LIT>' ) <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = dict ( external = '<STR_LIT>' , internal = '<STR_LIT>' ) <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> dict ( external = ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> internal = None ) , <EOL> ] ) <EOL> master = dict ( internal = '<STR_LIT>' ) <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , [ ] ) <EOL> def testExtractMastersMultiple ( self ) : <EOL> '''<STR_LIT>''' <EOL> console . terse ( "<STR_LIT>" . format ( self . testExtractMastersMultiple . __doc__ ) ) <EOL> master = [ <EOL> '<STR_LIT:localhost>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT:localhost>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> ] ) <EOL> master = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT:localhost>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> ] ) <EOL> master = [ <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ] <EOL> self . opts . update ( master = master ) <EOL> self . assertEquals ( extract_masters ( self . opts ) , <EOL> [ <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT:localhost>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) <EOL> } , <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> ] ) <EOL> def runOne ( test ) : <EOL> '''<STR_LIT>''' <EOL> test = BasicTestCase ( test ) <EOL> suite = unittest . TestSuite ( [ test ] ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> def runSome ( ) : <EOL> '''<STR_LIT>''' <EOL> tests = [ ] <EOL> names = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> tests . extend ( list ( list ( map ( BasicTestCase , names ) ) ) ) <EOL> suite = unittest . TestSuite ( tests ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> def runAll ( ) : <EOL> '''<STR_LIT>''' <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( unittest . TestLoader ( ) . loadTestsFromTestCase ( BasicTestCase ) ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> if __name__ == '<STR_LIT:__main__>' and __package__ is None : <EOL> runSome ( ) </s>
