Exemple #1
0
def parse_reference_expression(expression):
    try:
        return package_constraint_to_reference(PackageConstraint.parse(expression))
    except ValueError:
        # if we failed to parse the expression as constraint expression
        # we will try to parse it as reference
        return PackageReference.parse(expression)
def test_reference():
    package_constraint = PackageReference.parse(
        'swss@sha256:9780f6d83e45878749497a6297ed9906c19ee0cc48cc88dc63827564bb8768fd'
    )
    assert package_constraint.name == 'swss'
    assert package_constraint.reference == 'sha256:9780f6d83e45878749497a6297ed9906c19ee0cc48cc88dc63827564bb8768fd'
def test_reference_invalid():
    with pytest.raises(ValueError):
        PackageReference.parse('swssfdsf')