@ -13,42 +13,29 @@ import ansible.errors
import ansible . playbook . play_context
import ansible . playbook . play_context
import mitogen . core
import mitogen . core
import mitogen . utils
import ansible_mitogen . connection
import ansible_mitogen . connection
import ansible_mitogen . plugins . connection . mitogen_local
import ansible_mitogen . plugins . connection . mitogen_local
import ansible_mitogen . process
import ansible_mitogen . process
import testlib
LOGGER_NAME = ansible_mitogen . target . LOG . name
import testlib
# TODO: fixtureize
import mitogen . utils
mitogen . utils . log_to_file ( )
ansible_mitogen . process . MuxProcess . start ( _init_logging = False )
class OptionalIntTest ( unittest2 . TestCase ) :
func = staticmethod ( ansible_mitogen . connection . optional_int )
def test_already_int ( self ) :
self . assertEquals ( 0 , self . func ( 0 ) )
self . assertEquals ( 1 , self . func ( 1 ) )
self . assertEquals ( - 1 , self . func ( - 1 ) )
def test_is_string ( self ) :
self . assertEquals ( 0 , self . func ( " 0 " ) )
self . assertEquals ( 1 , self . func ( " 1 " ) )
self . assertEquals ( - 1 , self . func ( " -1 " ) )
def test_is_none ( self ) :
class MuxProcessMixin ( object ) :
self . assertEquals ( None , self . func ( None ) )
@classmethod
def setUpClass ( cls ) :
#mitogen.utils.log_to_file()
ansible_mitogen . process . MuxProcess . start ( _init_logging = False )
super ( MuxProcessMixin , cls ) . setUpClass ( )
def test_is_junk ( self ) :
@classmethod
self . assertEquals ( None , self . func ( { 1 : 2 } ) )
def tearDownClass ( cls ) :
super ( MuxProcessMixin , cls ) . tearDownClass ( )
ansible_mitogen . process . MuxProcess . _reset ( )
class ConnectionMixin ( object ) :
class ConnectionMixin ( MuxProcessMixin ) :
klass = ansible_mitogen . plugins . connection . mitogen_local . Connection
klass = ansible_mitogen . plugins . connection . mitogen_local . Connection
def make_connection ( self ) :
def make_connection ( self ) :
@ -70,6 +57,26 @@ class ConnectionMixin(object):
super ( ConnectionMixin , self ) . tearDown ( )
super ( ConnectionMixin , self ) . tearDown ( )
class OptionalIntTest ( unittest2 . TestCase ) :
func = staticmethod ( ansible_mitogen . connection . optional_int )
def test_already_int ( self ) :
self . assertEquals ( 0 , self . func ( 0 ) )
self . assertEquals ( 1 , self . func ( 1 ) )
self . assertEquals ( - 1 , self . func ( - 1 ) )
def test_is_string ( self ) :
self . assertEquals ( 0 , self . func ( " 0 " ) )
self . assertEquals ( 1 , self . func ( " 1 " ) )
self . assertEquals ( - 1 , self . func ( " -1 " ) )
def test_is_none ( self ) :
self . assertEquals ( None , self . func ( None ) )
def test_is_junk ( self ) :
self . assertEquals ( None , self . func ( { 1 : 2 } ) )
class PutDataTest ( ConnectionMixin , unittest2 . TestCase ) :
class PutDataTest ( ConnectionMixin , unittest2 . TestCase ) :
def test_out_path ( self ) :
def test_out_path ( self ) :
path = tempfile . mktemp ( prefix = ' mitotest ' )
path = tempfile . mktemp ( prefix = ' mitotest ' )