def main(): args = parse_args() if args.all and args.summarize: print('artifactory-du: cannot both summarize and show all entries', file=sys.stderr) if args.summarize: if args.max_depth != 100: print( 'artifactory-du: warning: summarizing is the same as using --max-depth=0', file=sys.stderr) args.max_depth = 0 if args.verbose: init_logging() aql_query_dict, max_depth_print = prepare_aql( file=args.file, max_depth=args.max_depth, repository=args.repository, without_downloads=args.without_downloads, older_than=args.older_than) artifacts = artifactory_aql( artifactory_url=args.artifactory_url, aql_query_dict=aql_query_dict, username=args.username, password=args.password, ) print_str = out_as_du(artifacts, max_depth_print, args.human_readable, args.all) print(print_str)
def test_out_as_du_max_depth_all(): expected_result = """1K 1/2/filename11.txt 1K 1/2/filename12.txt 1K 2/2/filename21.txt 1K 2/2/filename22.txt""" result = out_as_du(ARTIFACTS, max_depth=100, human_readable=True, all=True) assert expected_result == result
def test_out_as_du_simple_human(): artifacts = [ {'name': 'filename1.txt', 'path': 'level1', 'size': 1024, }, ] expected_result = """1K level1""" result = out_as_du(artifacts, max_depth=1, human_readable=True, all=False) assert expected_result == result
def test_out_as_du_max_depth_0(): expected_result = """4K /""" result = out_as_du(ARTIFACTS, max_depth=0, human_readable=True, all=True) assert expected_result == result
def test_out_as_du_max_depth_2(): expected_result = """2K 1/2 2K 2/2""" result = out_as_du(ARTIFACTS, max_depth=2, human_readable=True, all=False) assert expected_result == result