| 20 | cls.bearerClient = Algorithmia.client(api_address="http://localhost:8080", bearer_token="simabcd123.token.token") |
| 21 | |
| 22 | def test_run(self): |
| 23 | name = "util/Echo" |
| 24 | inputs = "test" |
| 25 | |
| 26 | parser = argparse.ArgumentParser('CLI for interacting with Algorithmia') |
| 27 | |
| 28 | subparsers = parser.add_subparsers(help='sub cmd', dest='subparser_name') |
| 29 | parser_run = subparsers.add_parser('run', help='algo run <algo> [input options] <args..> [output options]') |
| 30 | |
| 31 | parser_run.add_argument('algo') |
| 32 | parser_run.add_argument('-d', '--data', action='store', help='detect input type', default=None) |
| 33 | parser_run.add_argument('-t', '--text', action='store', help='treat input as text', default=None) |
| 34 | parser_run.add_argument('-j', '--json', action='store', help='treat input as json data', default=None) |
| 35 | parser_run.add_argument('-b', '--binary', action='store', help='treat input as binary data', default=None) |
| 36 | parser_run.add_argument('-D', '--data-file', action='store', help='specify a path to an input file', |
| 37 | default=None) |
| 38 | parser_run.add_argument('-T', '--text-file', action='store', help='specify a path to a text file', |
| 39 | default=None) |
| 40 | parser_run.add_argument('-J', '--json-file', action='store', help='specify a path to a json file', |
| 41 | default=None) |
| 42 | parser_run.add_argument('-B', '--binary-file', action='store', help='specify a path to a binary file', |
| 43 | default=None) |
| 44 | parser_run.add_argument('--timeout', action='store', type=int, default=300, |
| 45 | help='specify a timeout (seconds)') |
| 46 | parser_run.add_argument('--debug', action='store_true', |
| 47 | help='print the stdout from the algo <this only works for the owner>') |
| 48 | parser_run.add_argument('--profile', action='store', type=str, default='default') |
| 49 | parser_run.add_argument('-o', '--output', action='store', default=None, type=str) |
| 50 | |
| 51 | args = parser.parse_args(['run', name, '-d', inputs]) |
| 52 | |
| 53 | result = CLI().runalgo(args, self.client) |
| 54 | self.assertEqual(result, inputs) |
| 55 | |
| 56 | def test_run_token(self): |
| 57 | name = "util/Echo" |