Sunday, April 26, 2020

How to Patch Methods with mock for python


def test_command_line_gitlab_blocker( LOAD, monkeypatch, get_client, cicd_context, session_context):
    def return_value(self):
        return []
    def update_purge(self,mock):
        return
    with patch.object(GitlabBlocker, 'find_all_to_be_blocked_users',return_value):
        with patch.object(GitlabBlocker, 'update_purge_action_dt', update_purge):
            sys.argv =['gitlab_blocker.py', '--test','cycle','-f', 'my_test.cfg']
            runpy.run_module('gitlab_blocker', run_name='__main__')





class GitlabBlocker(object):
    
    def __init__(self, config, gitlab_client, test = 'cycle'):
    
    def _open(self):

    def find_all_to_be_blocked_users(self):

    def update_purge_action_dt(self, uuid):
        
    def blocking(self, no_Block_call=False):