#!/usr/bin/env python # coding: utf-8 # In[ ]: from build_docker import * import unittest import pprint DEBUG_MODE = True this_script_path = os.path.realpath('__file__') TEST_BUILD_TAG = 'mytest' # In[ ]: # test if build chain can be constructed in desired order print( Project_Build.get_ordered_build_chain_single('manta') ) print( Project_Build.get_ordered_build_chain_single('delly') ) print( Project_Build.get_ordered_build_chain_single('melt') ) print( Project_Build.get_ordered_build_chain_single('wham') ) print( Project_Build.get_ordered_build_chain_single('sv-base-mini') ) print() print( Project_Build.get_ordered_build_chain_single('sv-base') ) print( Project_Build.get_ordered_build_chain_single('samtools-cloud') ) print( Project_Build.get_ordered_build_chain_single('sv-pipeline') ) print( Project_Build.get_ordered_build_chain_single('cnmops') ) print() print( Project_Build.get_ordered_build_chain_single('sv-pipeline-rdtest') ) print( Project_Build.get_ordered_build_chain_single('sv-pipeline-qc') ) print( Project_Build.get_ordered_build_chain_list(['manta']) ) print( Project_Build.get_ordered_build_chain_list(['delly']) ) print( Project_Build.get_ordered_build_chain_list(['melt']) ) print( Project_Build.get_ordered_build_chain_list(['wham']) ) print( Project_Build.get_ordered_build_chain_list(['sv-base-mini']) ) print() print( Project_Build.get_ordered_build_chain_list(['sv-base']) ) print( Project_Build.get_ordered_build_chain_list(['samtools-cloud']) ) print( Project_Build.get_ordered_build_chain_list(['sv-pipeline']) ) print( Project_Build.get_ordered_build_chain_list(['cnmops']) ) print() print( Project_Build.get_ordered_build_chain_list(['sv-pipeline-rdtest']) ) print( Project_Build.get_ordered_build_chain_list(['sv-pipeline-qc']) ) print( Project_Build.get_ordered_build_chain_list(['manta','delly','melt','wham','sv-base-mini']) ) print( Project_Build.get_ordered_build_chain_list(['sv-base','samtools-cloud','sv-pipeline','cnmops']) ) print( Project_Build.get_ordered_build_chain_list(['sv-pipeline-rdtest','sv-pipeline-qc']) ) print( Project_Build.get_ordered_build_chain_list(['manta', 'cnmops', 'sv-pipeline-rdtest','sv-pipeline-qc']) ) # In[ ]: # args for testing consistency check functionality # illegal build target TEST_ARGS_FAIL_ILLEGAL_TARGET = ['--targets', 'manta', 'caller', '--image-tag', TEST_BUILD_TAG] # too many targets TEST_ARGS_FAIL_TOO_MANY_TARGET = ['--targets', 'all', 'manta', '--image-tag', TEST_BUILD_TAG] # forget to provide staging dir when building from remote source TEST_ARGS_FAIL_FORGOT_STAGING = ['--targets', 'all', '--image-tag', TEST_BUILD_TAG, '--remote-git-hash', '7d3795cf14ff9e414d632f7912584768d9c8a0e1'] # mix remote and local build mode TEST_ARGS_FAIL_LOCAL_REMOTE_MIX = ['--targets', 'all', '--image-tag', TEST_BUILD_TAG, '--use-ssh'] # update "latest" from local files, prohibitted TEST_ARGS_FAIL_NO_LATEST = ['--targets', 'all', '--image-tag', TEST_BUILD_TAG, '--dockerhub-root', 'shuangbroad', '--update-latest'] TEST_CASES = (TEST_ARGS_FAIL_ILLEGAL_TARGET, TEST_ARGS_FAIL_TOO_MANY_TARGET, TEST_ARGS_FAIL_FORGOT_STAGING, TEST_ARGS_FAIL_LOCAL_REMOTE_MIX, TEST_ARGS_FAIL_NO_LATEST) ########## if DEBUG_MODE: for tt in TEST_CASES: try: test_parser = CMD_line_args_parser(tt) except UserError as e: print("Successfully caught user error:\n" + str(e)) else: raise RuntimeError("Failed to capture mistakes")