Skip to content

Commit

Permalink
fixed tests for Agent_0
Browse files Browse the repository at this point in the history
  • Loading branch information
mtitov committed Sep 29, 2023
1 parent 24d21b9 commit 57bfad7
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tests/unit_tests/test_agent_0/test_agent_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def test_check_control_cb(self, mocked_init):

def _publish_effect(publish_type, cmd):
nonlocal global_control
import pprint
print('=============== pub', pprint.pformat(cmd))
global_control.append((publish_type, cmd))

def _prepenv_effect(env_name, env_spec):
Expand Down Expand Up @@ -102,7 +100,6 @@ def _prepenv_effect(env_name, env_spec):
'kwargs': {'env_name': 'radical',
'env_spec': 'spec'}})
self.assertIsNone(agent_cmp._control_cb(None, msg))
print('====', global_control, '====')
self.assertEqual(global_control[0],
('control_pubsub',
RPCResultMessage({'uid': 'rpc.0004',
Expand Down Expand Up @@ -191,29 +188,35 @@ def local_advance(things, publish, push):
advanced_services = things

agent_0 = Agent_0()
agent_0._session = self._session
agent_0.advance = local_advance
agent_0._uid = 'agent_0'
agent_0._cb_lock = mt.RLock()
agent_0._threads = dict()
agent_0._log = mock.Mock()
agent_0._service_uids_launched = list()
agent_0._services_setup = mock.Mock()

agent_0._cfg = ru.Config(from_dict={'pid' : 12,
'pilot_sandbox': '/',
'services' : []})
agent_0.advance = local_advance

agent_0._session = self._session
agent_0._session._cfg = ru.Config(from_dict={'pid' : 12,
'pilot_sandbox': '/',
'services' : []})

agent_0._cfg.services = [{}]
agent_0._session._cfg.services = [{}]
with self.assertRaises(ValueError):
# no executable provided
agent_0._start_services()

agent_0._cfg.services = [{'executable': 'test', 'ranks': 'zero'}]
agent_0._session._cfg.services = [{'executable': 'test',
'ranks' : 'zero'}]
with self.assertRaises(TypeError):
# type mismatch
agent_0._start_services()

services = [{'executable': '/bin/ls',
'cores_per_rank': '3'}]
agent_0._cfg.services = services
services = [{'executable' : '/bin/ls',
'cores_per_rank': '3',
'metadata' : {}}]
agent_0._session._cfg.services = services

agent_0._services_setup.wait = mock.Mock(return_value=True)
agent_0._start_services()
Expand Down

0 comments on commit 57bfad7

Please sign in to comment.