def test():

    # This worker test requires a local server running
    import zerorpc
    workbench = zerorpc.Client(timeout=300, heartbeat=60)
    workbench.connect('tcp://127.0.0.1:4242')

    # Generate 3 different inputs for the worker (better coverage)
    import os
    data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             '../data/pe/bad/033d91aae8ad29ed9fbb858179271232')
    md5 = workbench.store_sample(open(data_path, 'rb').read(), 'bad_pe', 'exe')
    data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             '../data/pe/good/4be7ec02133544cde7a580875e130208')
    md5_2 = workbench.store_sample(open(data_path, 'rb').read(), 'good_pe', 'exe')
    input_data = workbench.get_sample(md5)
    input_data.update(workbench.work_request('tags', md5))
    input_data_2 = workbench.get_sample(md5_2)
    input_data_2.update(workbench.work_request('tags', md5_2))
    input_data_3 = {'sample': {'raw_bytes': 'invalid pe file to hit exception code'}}

    # Execute the worker (unit test)
    worker = PEFileWorker()
    output = worker.execute(input_data)
    print '\n<<< Unit Test >>>'
    pprint.pprint(output)    

    # For code coverage
    output = worker.execute(input_data_2)
    output = worker.execute(input_data_3)

    # Execute the worker (server test)
    output = workbench.work_request('pe_features', md5)
    print '\n<<< Server Test >>>'
    pprint.pprint(output)
pe_features.py: Test
dataset/ETHPy150Open SuperCowPowers/workbench/workbench/workers/pe_features.py/test