def test_update_agent(self, mock_agent_instances, mock_agent): mock_agent.updateOrInsert.return_value = ('agent1', None) mock_agent_instances.roleExists.return_value = None test_agent = {'name': 'agent1'} testInstance = Instance() testInstance.updateAgent(test_agent) mock_agent_instances.assert_has_calls([ call.roleExists(None, 'agent1', 'author', None), call(agent='agent1', instance=testInstance, role='author') ])
def test_update_agent(self, mock_agent_instances, mock_agent): mock_agent.updateOrInsert.return_value = ('agent1', None) mock_agent_instances.roleExists.return_value = None test_agent = {'name': 'agent1'} mockSession = MagicMock() testInstance = Instance(session=mockSession) testInstance.updateAgent(test_agent) mock_agent_instances.assert_has_calls([ call.roleExists(mockSession, 'agent1', 'author', None), call(agent='agent1', instance=testInstance, role='author') ]) mockSession.add.assert_called_once()