Esempio n. 1
0
def test_args_parse_input_files2():
    input_dict = {
        'args': {
            'input_files': {
                "file1":
                [["s3://somebucket/somekey1", "s3://somebucket/somekey2"],
                 ["s3://somebucket/somekey3", "s3://somebucket/somekey4"]]
            },
            'output_S3_bucket': 'somebucket',
            'cwl_main_filename': 'main.cwl',
            'cwl_directory_url': 'someurl',
            'app_name': 'someapp'
        }
    }
    args = Args(**input_dict['args'])
    args.fill_default()
    assert hasattr(args, 'input_files')
    assert 'file1' in args.input_files
    assert 'bucket_name' in args.input_files['file1']
    assert 'object_key' in args.input_files['file1']
    assert args.input_files['file1']['bucket_name'] == 'somebucket'
    assert isinstance(args.input_files['file1']['object_key'], list)
    assert len(args.input_files['file1']['object_key']) == 2
    assert isinstance(args.input_files['file1']['object_key'][0], list)
    assert len(args.input_files['file1']['object_key'][0]) == 2
    assert isinstance(args.input_files['file1']['object_key'][1], list)
    assert len(args.input_files['file1']['object_key'][1]) == 2
    assert args.input_files['file1']['object_key'][0][0] == 'somekey1'
    assert args.input_files['file1']['object_key'][0][1] == 'somekey2'
    assert args.input_files['file1']['object_key'][1][0] == 'somekey3'
    assert args.input_files['file1']['object_key'][1][1] == 'somekey4'
Esempio n. 2
0
def test_parse_command():
    input_dict = {
        'args': {
            'command': ['command1', 'command2', 'command3'],
            'output_S3_bucket': 'somebucket',
            'language': 'shell',
            'container_image': 'someimage',
            'app_name': 'someapp'
        }
    }
    args = Args(**input_dict['args'])
    args.fill_default()
    assert args.command == 'command1; command2; command3'
Esempio n. 3
0
def test_args():
    input_dict = {
        'args': {
            'input_files': {},
            'output_S3_bucket': 'somebucket',
            'app_name': 'someapp'
        }
    }
    args = Args(**input_dict['args'])
    args_dict = args.as_dict()
    assert 'input_files' in args_dict
    assert 'app_name' in args_dict
    assert args_dict['app_name'] == 'someapp'
Esempio n. 4
0
def test_args_parse_input_files_format_error():
    input_dict = {
        'args': {
            'input_files': {
                "file1": "somerandomstr"
            },
            'output_S3_bucket': 'somebucket',
            'cwl_main_filename': 'main.cwl',
            'cwl_directory_url': 'someurl',
            'app_name': 'someapp'
        }
    }
    args = Args(**input_dict['args'])
    with pytest.raises(MalFormattedInputJsonException) as ex:
        args.fill_default()
    assert ex
    assert 'S3 url must begin with' in str(ex.value)
Esempio n. 5
0
def test_args_parse_input_files_format_error2():
    input_dict = {
        'args': {
            'input_files': {
                "file1":
                ["s3://somebucket/somekey1", "s3://otherbucket/somekey2"]
            },
            'output_S3_bucket': 'somebucket',
            'cwl_main_filename': 'main.cwl',
            'cwl_directory_url': 'someurl',
            'app_name': 'someapp'
        }
    }
    args = Args(**input_dict['args'])
    with pytest.raises(MalFormattedInputJsonException) as ex:
        args.fill_default()
    assert ex
    assert 'bucket' in str(ex.value)
Esempio n. 6
0
def test_args_parse_input_files():
    input_dict = {
        'args': {
            'input_files': {
                "file1": "s3://somebucket/somekey"
            },
            'output_S3_bucket': 'somebucket',
            'cwl_main_filename': 'main.cwl',
            'cwl_directory_url': 'someurl',
            'app_name': 'someapp'
        }
    }
    args = Args(**input_dict['args'])
    args.fill_default()
    assert hasattr(args, 'input_files')
    assert 'file1' in args.input_files
    assert 'bucket_name' in args.input_files['file1']
    assert 'object_key' in args.input_files['file1']
    assert args.input_files['file1']['bucket_name'] == 'somebucket'
    assert args.input_files['file1']['object_key'] == 'somekey'
Esempio n. 7
0
def test_args_input_files_w_mount():
    input_dict = {
        'args': {
            'input_files': {
                "file1": {
                    "bucket_name": "a",
                    "object_key": "b",
                    "mount": True
                }
            },
            'output_S3_bucket': 'somebucket',
            'cwl_main_filename': 'main.cwl',
            'cwl_directory_url': 'someurl',
            'app_name': 'someapp'
        }
    }
    args = Args(**input_dict['args'])
    assert args.input_files['file1']['mount']
Esempio n. 8
0
def test_args_missing_field():
    input_dict = {'args': {'input_files': {}, 'app_name': 'someapp'}}
    with pytest.raises(MissingFieldInInputJsonException) as ex:
        Args(**input_dict['args'])
    assert ex
    assert 'output_S3_bucket' in str(ex.value)