<s> __author__ = '<STR_LIT>' <EOL> from pyon . util . int_test import IonIntegrationTestCase <EOL> from pyon . util . unit_test import PyonTestCase <EOL> from nose . plugins . attrib import attr <EOL> from pyon . container . cc import Container , CCAP <EOL> import signal <EOL> from gevent . event import Event <EOL> from mock import Mock , patch , ANY <EOL> from interface . services . icontainer_agent import ContainerAgentClient <EOL> from interface . objects import ProcessStateEnum <EOL> @ attr ( '<STR_LIT>' ) <EOL> class TestCC ( PyonTestCase ) : <EOL> def setUp ( self ) : <EOL> self . cc = Container ( ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_fail_fast ( self , osmock , logmock ) : <EOL> self . cc . stop = Mock ( ) <EOL> self . cc . fail_fast ( '<STR_LIT>' ) <EOL> self . assertIn ( '<STR_LIT>' , str ( logmock . error . call_args_list [ <NUM_LIT:0> ] ) ) <EOL> self . cc . stop . assert_called_once_with ( ) <EOL> osmock . kill . assert_called_once_with ( osmock . getpid ( ) , signal . SIGTERM ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_fail_fast_no_stop ( self , osmock ) : <EOL> self . cc . stop = Mock ( ) <EOL> self . cc . fail_fast ( "<STR_LIT>" , True ) <EOL> self . assertEquals ( self . cc . stop . call_count , <NUM_LIT:0> ) <EOL> def test_node_when_not_started ( self ) : <EOL> self . assertEquals ( self . cc . node , None ) <EOL> def test_node_when_started ( self ) : <EOL> self . cc . _capabilities . append ( "<STR_LIT>" ) <EOL> self . cc . ex_manager = Mock ( ) <EOL> self . assertEquals ( self . cc . node , self . cc . ex_manager . default_node ) <EOL> @ attr ( '<STR_LIT>' ) <EOL> class TestCCInt ( IonIntegrationTestCase ) : <EOL> def test_start_hello ( self ) : <EOL> self . _start_container ( ) <EOL> cc_client = ContainerAgentClient ( node = self . container . node , name = self . container . name ) <EOL> p = cc_client . spawn_process ( '<STR_LIT:hello>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ attr ( '<STR_LIT>' ) <EOL> class TestCCIntProcs ( IonIntegrationTestCase ) : <EOL> class ExpectedFailure ( StandardError ) : <EOL> pass <EOL> def setUp ( self ) : <EOL> self . cc = Container ( ) <EOL> self . cc . resource_registry = Mock ( ) <EOL> self . cc . resource_registry . create . return_value = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . cc . event_pub = Mock ( ) <EOL> self . cc . proc_manager . start ( ) <EOL> self . cc . stop = Mock ( ) <EOL> self . cc . stop . side_effect = self . cc . proc_manager . stop <EOL> def tearDown ( self ) : <EOL> pass <EOL> @ attr ( '<STR_LIT>' ) <EOL> class TestContainerCapabilities ( IonIntegrationTestCase ) : <EOL> def test_development ( self ) : <EOL> from pyon . container . cc import CFG <EOL> old_profile = CFG . container . profile <EOL> CFG . container . profile = "<STR_LIT>" <EOL> try : <EOL> self . _start_container ( ) <EOL> self . assertIn ( CCAP . RESOURCE_REGISTRY , self . container . _capabilities ) <EOL> self . assertEquals ( self . container . _cap_instances [ CCAP . RESOURCE_REGISTRY ] . __class__ . __name__ , "<STR_LIT>" ) <EOL> self . assertIn ( CCAP . EVENT_REPOSITORY , self . container . _capabilities ) <EOL> self . assertIn ( CCAP . GOVERNANCE_CONTROLLER , self . container . _capabilities ) <EOL> self . assertGreater ( len ( self . container . _capabilities ) , <NUM_LIT:15> ) <EOL> self . assertEqual ( CFG . get_safe ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> finally : <EOL> CFG . container . profile = old_profile <EOL> def test_gumstix ( self ) : <EOL> from pyon . container . cc import CFG <EOL> old_profile = CFG . container . profile <EOL> CFG . container . profile = "<STR_LIT>" <EOL> try : <EOL> self . _start_container ( ) <EOL> self . assertIn ( CCAP . RESOURCE_REGISTRY , self . container . _capabilities ) <EOL> self . assertEquals ( self . container . _cap_instances [ CCAP . RESOURCE_REGISTRY ] . __class__ . __name__ , "<STR_LIT>" ) <EOL> self . assertNotIn ( CCAP . EVENT_REPOSITORY , self . container . _capabilities ) <EOL> self . assertNotIn ( CCAP . GOVERNANCE_CONTROLLER , self . container . _capabilities ) <EOL> self . assertLess ( len ( self . container . _capabilities ) , <NUM_LIT:15> ) <EOL> finally : <EOL> CFG . container . profile = old_profile </s>
