def test_dict_of_mixed_input_types(): input_list = _TrainingJob._format_inputs_to_input_config({ 'a': 's3://foo/bar', 'b': s3_input('s3://whizz/bang') }) expected = [{ 'ChannelName': 'a', 'DataSource': { 'S3DataSource': { 'S3DataDistributionType': 'FullyReplicated', 'S3DataType': 'S3Prefix', 'S3Uri': 's3://foo/bar' } } }, { 'ChannelName': 'b', 'DataSource': { 'S3DataSource': { 'S3DataDistributionType': 'FullyReplicated', 'S3DataType': 'S3Prefix', 'S3Uri': 's3://whizz/bang' } } }] # convert back into map for comparison so list order (which is arbitrary) is ignored assert {c['ChannelName']: c for c in input_list} == {c['ChannelName']: c for c in expected}
def test_format_input_single_unamed_channel(): input_dict = _TrainingJob._format_inputs_to_input_config('s3://blah/blah') assert input_dict == [{ 'ChannelName': 'training', 'DataSource': { 'S3DataSource': { 'S3DataDistributionType': 'FullyReplicated', 'S3DataType': 'S3Prefix', 'S3Uri': 's3://blah/blah' } } }]
def test_format_input_s3_input(): input_dict = _TrainingJob._format_inputs_to_input_config( s3_input('s3://foo/bar', distribution='ShardedByS3Key', compression='gzip', content_type='whizz', record_wrapping='bang')) assert input_dict == [{ 'CompressionType': 'gzip', 'ChannelName': 'training', 'ContentType': 'whizz', 'DataSource': { 'S3DataSource': { 'S3DataType': 'S3Prefix', 'S3DataDistributionType': 'ShardedByS3Key', 'S3Uri': 's3://foo/bar' } }, 'RecordWrapperType': 'bang' }]
def test_unsupported_type_in_dict(): with pytest.raises(ValueError): _TrainingJob._format_inputs_to_input_config({'a': 66})
def test_unsupported_type_in_dict(): with pytest.raises(ValueError) as error: _TrainingJob._format_inputs_to_input_config({'a': 66}) assert 'Expecting one of str or s3_input' in str(error)
def test_unsupported_type(): with pytest.raises(ValueError): _TrainingJob._format_inputs_to_input_config(55)
def test_unsupported_type_in_dict(): with pytest.raises(ValueError): _TrainingJob._format_inputs_to_input_config({'a': 66})