def test_mpdrmq_after_execute(self, mocked): """ Test that the call to after_execute call superclass after_execute""" agentconf={} mpdconf={"host":"mpd.lan"} rmqconf={"host":"rmq.lan"} agent=MpdRmqAgent(agentconf, mpdconf, rmqconf) #Setup generic mock for others methods wich are not tested here ignoredmocks=Mock() agent.mpdclient=ignoredmocks agent.rmqclient=ignoredmocks agent.after_execute() mocked.assert_called_with(agent)
def test_mpdrmq_after_execute_exception(self): """ Test that the call to after_execute call superclass after_execute""" agentconf={} mpdconf={"host":"mpd.lan"} rmqconf={"host":"rmq.lan"} agent=MpdRmqAgent(agentconf, mpdconf, rmqconf) #Setup generic mock for others methods wich are not tested here ignoredmocks=Mock() agent.mpdclient=ignoredmocks agent.rmqclient=ignoredmocks agent.rmqclient.disconnect.side_effect=Exception("In your face") with self.assertRaises(MpdRmqException): agent.ensure_after_execute()
def test_mpdrmq_agent_run_call_connect(self): agentconf={} mpdconf={"host":"mpd.lan"} rmqconf={"host":"rmq.lan"} agent=MpdRmqAgent(agentconf, mpdconf, rmqconf) mpdmock=Mock() agent.mpdclient=mpdmock rmqmock=Mock() agent.rmqclient=rmqmock # Mock the execute method to get rid of Not implemented exceptions execute=Mock() agent.execute=execute agent.run() mpdmock.connect.assert_called_with() mpdmock.connect.assert_called_with() rmqmock.disconnect.assert_called_with() rmqmock.disconnect.assert_called_with()
def __init__(self, config={}, mpdconf={}, rmqconf={}): MpdRmqAgent.__init__(self, config, mpdconf, rmqconf)