Beispiel #1
0
def test_md5_for_extra(update_ffmeta_event_data_extra_md5):
    updater = FourfrontUpdater(**update_ffmeta_event_data_extra_md5)
    assert updater.input_argnames[0] == 'input_file'
    assert 'format_if_extra' in updater.ff_file('input_file')
    format_if_extras = updater.format_if_extras(updater.input_argnames[0])
    assert len(format_if_extras) == 1
    assert format_if_extras[0] == 'pairs_px2'
    updater.update_md5()
    assert updater.bucket('report') == 'elasticbeanstalk-fourfront-webdev-wfoutput'
    assert updater.file_key('report') == 'f1340bec-a842-402c-bbac-6e239df96682/report822085265412'
    assert updater.status('report') == 'COMPLETED'
    assert '12005967-f060-40dd-a63c-c7204dcf46a7' in updater.patch_items
    assert 'md5sum' in updater.patch_items['12005967-f060-40dd-a63c-c7204dcf46a7']['extra_files'][0]
    assert 'content_md5sum' in updater.patch_items['12005967-f060-40dd-a63c-c7204dcf46a7']['extra_files'][0]
    assert 'file_size' in updater.patch_items['12005967-f060-40dd-a63c-c7204dcf46a7']['extra_files'][0]
Beispiel #2
0
def test_md5(update_ffmeta_event_data_newmd5):
    report_key = 'lalala/md5_report'
    s3 = boto3.client('s3')
    s3.put_object(Body='1234\n5678'.encode('utf-8'),
                  Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key)
    updater = FourfrontUpdater(**update_ffmeta_event_data_newmd5)
    assert updater.app_name == 'md5'
    with pytest.raises(Exception) as exec_info:
        updater.update_md5()
    assert 'md5sum not matching the original one' in str(exec_info.value)
    real_md5_content = 'bc75002f8a473bc6854d562789525a90\n6bb2dfa5b435ed03105cb59c32442d23'
    s3.put_object(Body=real_md5_content.encode('utf-8'),
                  Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key)
    updater.update_md5()
    md5, content_md5 = updater.parse_md5_report(updater.read('report'))
    assert md5 == 'bc75002f8a473bc6854d562789525a90'
    assert content_md5 == '6bb2dfa5b435ed03105cb59c32442d23'
    assert 'f4864029-a8ad-4bb8-93e7-5108f462ccaa' in updater.patch_items
    assert 'md5sum' not in updater.patch_items['f4864029-a8ad-4bb8-93e7-5108f462ccaa']  # already in
    assert 'file_size' in updater.patch_items['f4864029-a8ad-4bb8-93e7-5108f462ccaa']
    s3.delete_object(Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key)