diff --git a/tests/payload/test_payload.py b/tests/payload/test_payload.py index 202fe8f75..0ced76807 100644 --- a/tests/payload/test_payload.py +++ b/tests/payload/test_payload.py @@ -22,5 +22,5 @@ async def test_payload(): assert builder.properties == {"golem.srv.app.foo.port": 1234} assert ( builder.constraints - == "((&(golem.runtime.name=foo)\n\t(golem.inf.mem.gib>=32)\n\t(golem.inf.storage.gib>=1024)))" + == "(&(golem.runtime.name=foo)\n\t(golem.inf.mem.gib>=32)\n\t(golem.inf.storage.gib>=1024))" ) diff --git a/tests/props/test_base.py b/tests/props/test_base.py index 42abf3ef3..2509d1587 100644 --- a/tests/props/test_base.py +++ b/tests/props/test_base.py @@ -77,19 +77,19 @@ def test_constraint_model_serialize(): ( FooToo, "!", - "(!((baz=21)))", + "(!(baz=21))", False, ), ( FooToo, "&", - "((baz=21))", + "(baz=21)", False, ), ( FooToo, "|", - "((baz=21))", + "(baz=21)", False, ), ( diff --git a/tests/props/test_builder.py b/tests/props/test_builder.py index 83baf5b42..ab7f4d7c6 100644 --- a/tests/props/test_builder.py +++ b/tests/props/test_builder.py @@ -16,4 +16,4 @@ class Foo(AutodecoratingModel): demand = DemandBuilder() await foo.decorate_demand(demand) assert demand.properties == {"some.bar": "a nice one"} - assert demand.constraints == "(((baz<=50)))" + assert demand.constraints == "(baz<=50)" diff --git a/yapapi/props/base.py b/yapapi/props/base.py index 5edc823a2..b6022a8e1 100644 --- a/yapapi/props/base.py +++ b/yapapi/props/base.py @@ -318,7 +318,7 @@ def join_str_constraints(constraints: List[str], operator: ConstraintGroupOperat """ if operator == "!": if len(constraints) == 1: - return f"({operator}({constraints[0]}))" + return f"({operator}{constraints[0]})" else: raise ConstraintException(f"{operator} requires exactly one component.") @@ -326,7 +326,7 @@ def join_str_constraints(constraints: List[str], operator: ConstraintGroupOperat return f"({operator})" if len(constraints) == 1: - return f"({constraints[0]})" + return f"{constraints[0]}" rules = "\n\t".join(constraints) return f"({operator}{rules})"