Skip to content

Commit

Permalink
squash: extend test
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily committed May 14, 2024
1 parent a3894a1 commit 483c7b4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
37 changes: 31 additions & 6 deletions tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
_parse_memory,
_parse_virtualization,
_parse_zcrypt,
_parse_location,
)
from tmt.log import Logger
from tmt.steps.provision.mrack import (
Expand Down Expand Up @@ -231,6 +232,12 @@ def test_maximal_constraint(root_logger: Logger) -> None:
'_value': '%.foo.redhat.com'
}
},
{
'labcontroller': {
'_op': '!=',
'_value': 'lab-01.rhts.eng.pek2.redhat.com'
}
},
{'or': []},
{
'and': [
Expand Down Expand Up @@ -278,12 +285,6 @@ def test_maximal_constraint(root_logger: Logger) -> None:
]
},

{
'labcontroller': {
'_op': '!=',
'_value': 'lab-01.rhts.eng.pek2.redhat.com'
}
},
]
}

Expand Down Expand Up @@ -678,3 +679,27 @@ def test_zcrypt_mode(root_logger: Logger) -> None:
}
}
}



def test_location_lab_controller(root_logger: Logger) -> None:

result = _CONSTRAINT_TRANSFORMERS['location.lab_controller'](
_parse_location({"lab-controller": "lab-01.rhts.eng.pek2.redhat.com"}), root_logger)

assert result.to_mrack() == {
'labcontroller': {
'_op': '==',
'_value': 'lab-01.rhts.eng.pek2.redhat.com'
}
}

result = _CONSTRAINT_TRANSFORMERS['location.lab_controller'](
_parse_location({"lab-controller": "!= lab-01.rhts.eng.pek2.redhat.com"}), root_logger)

assert result.to_mrack() == {
'labcontroller': {
'_op': '!=',
'_value': 'lab-01.rhts.eng.pek2.redhat.com'
}
}
6 changes: 3 additions & 3 deletions tmt/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ def _parse_location(spec: Spec) -> BaseConstraint:
if 'lab-controller' in spec:
group.constraints += [
TextConstraint.from_specification(
'location.lab-controller',
'location.lab_controller',
spec['lab-controller'],
allowed_operators=[Operator.EQ, Operator.NEQ, Operator.MATCH, Operator.NOTMATCH])
]
Expand Down Expand Up @@ -1332,10 +1332,10 @@ def _parse_generic_spec(spec: Spec) -> BaseConstraint:
group.constraints += [_parse_hostname(spec)]

if 'location' in spec:
group.constraints += [_parse_location(spec)]
group.constraints += [_parse_location(spec['location'])]

if 'system' in spec:
group.constraints += [_parse_system(spec)]
group.constraints += [_parse_system(spec['system'])]

if 'tpm' in spec:
group.constraints += [_parse_tpm(spec['tpm'])]
Expand Down

0 comments on commit 483c7b4

Please sign in to comment.