示例#1
0
def test_validate_invalid_checksum():
    with open(os.path.join(BASE_PATH, 'test_e.bps'), 'rb') as patch:
        with pytest.raises(ValueError) as excinfo:
            bps.validate_patch(patch)
        assert 'Invalid checksum.' in str(excinfo.value)
示例#2
0
def test_validate_invalid_metadata_size():
    with open(os.path.join(BASE_PATH, 'test_h.bps'), 'rb') as patch:
        with pytest.raises(ValueError) as excinfo:
            bps.validate_patch(patch)
        assert str(excinfo.value) == 'Failed to decode metadata size.'
示例#3
0
def test_validate_too_small():
    with open(os.path.join(BASE_PATH, 'test_c.bps'), 'rb') as patch:
        with pytest.raises(ValueError) as excinfo:
            bps.validate_patch(patch)
        assert str(excinfo.value) == 'Patch too short.'
示例#4
0
def test_validate_wrong_format():
    with open(os.path.join(BASE_PATH, 'test_d.bps'), 'rb') as patch:
        with pytest.raises(ValueError) as excinfo:
            bps.validate_patch(patch)
        assert str(excinfo.value) == 'Invalid file format marker.'
示例#5
0
def test_validate(bps_path):
    with open(bps_path, 'rb') as bps_file:
        bps.validate_patch(bps_file)
示例#6
0
def test_validate_source_read_beyond_end():
    with open(os.path.join(BASE_PATH, 'test_j.bps'), 'rb') as patch:
        with pytest.raises(ValueError) as excinfo:
            bps.validate_patch(patch)
        assert str(excinfo.value).startswith('Attempted to read beyond end of source.')
示例#7
0
def test_validate_invalid_metadata_size_overflow():
    with open(os.path.join(BASE_PATH, 'test_i.bps'), 'rb') as patch:
        with pytest.raises(ValueError) as excinfo:
            bps.validate_patch(patch)
        assert str(excinfo.value) == 'Metadata size too large.'