<s> from mock import patch <EOL> from cloudferry . lib . utils import node_ip <EOL> from tests import test <EOL> class NodeIPTestCase ( test . TestCase ) : <EOL> @ patch ( "<STR_LIT>" ) <EOL> @ patch . object ( node_ip , "<STR_LIT>" ) <EOL> def test_falls_back_to_node_ip ( self , get_ips_mock , socket_mock ) : <EOL> ext_cidr = [ "<STR_LIT>" ] <EOL> init_host = "<STR_LIT>" <EOL> compute_host = "<STR_LIT>" <EOL> user = "<STR_LIT:user>" <EOL> expected = "<STR_LIT>" <EOL> get_ips_mock . return_value = [ ] <EOL> socket_mock . gethostbyname . return_value = expected <EOL> ip = node_ip . get_ext_ip ( ext_cidr , init_host , compute_host , user ) <EOL> self . assertEqual ( expected , ip ) <EOL> @ patch . object ( node_ip , "<STR_LIT>" ) <EOL> def test_returns_correct_ip_if_available ( self , get_ips_mock ) : <EOL> ext_cidr = [ "<STR_LIT>" ] <EOL> init_host = "<STR_LIT>" <EOL> compute_host = "<STR_LIT>" <EOL> user = "<STR_LIT:user>" <EOL> expected = "<STR_LIT>" <EOL> get_ips_mock . return_value = [ expected , "<STR_LIT>" , "<STR_LIT>" ] <EOL> ip = node_ip . get_ext_ip ( ext_cidr , init_host , compute_host , user ) <EOL> self . assertEqual ( expected , ip ) </s>
