Skip to content

Commit

Permalink
test: Fix tests using wrong assumptions
Browse files Browse the repository at this point in the history
Some tests wrongly assumed that `LiteralNumericValue.value` would be a
numeric value instead of a string (silly, I know). The metamodel fix in
0329cdb broke those tests; this commit
fixes them (and removes the ones that can't be fixed).
  • Loading branch information
Wuestengecko committed Dec 15, 2023
1 parent 9993dcc commit b3a0738
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 42 deletions.
13 changes: 0 additions & 13 deletions tests/test_auditing.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ def audit(event: str, _: tuple[t.Any, ...]) -> None:
common.HTMLAttributeProperty,
id="HTMLAttributeProperty",
),
pytest.param(
"303c2a4d-0eff-41e6-b7e8-0e500cfa38f7",
"value",
common.NumericAttributeProperty,
id="NumericAttributeProperty",
),
pytest.param(
"b97c09b5-948a-46e8-a656-69d764ddce7d",
"value",
Expand Down Expand Up @@ -254,13 +248,6 @@ def test_attribute_access_fires_read_attribute_events(
common.HTMLAttributeProperty,
id="HTMLAttributeProperty",
),
pytest.param(
"303c2a4d-0eff-41e6-b7e8-0e500cfa38f7",
"value",
lambda o: o.value + 1,
common.NumericAttributeProperty,
id="NumericAttributeProperty",
),
pytest.param(
"b97c09b5-948a-46e8-a656-69d764ddce7d",
"value",
Expand Down
28 changes: 0 additions & 28 deletions tests/test_model_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations

import math
import operator
import typing as t

Expand Down Expand Up @@ -1077,33 +1076,6 @@ def test_ComponentExchange_has_allocating_PhysicalPath(
assert cex.allocating_physical_paths == [path]


@pytest.mark.parametrize(
["attr", "value"],
[("min_card", 1), ("max_card", math.inf)],
)
def test_literal_numeric_value_star_is_infinity(
model: capellambse.MelodyModel, attr: str, value: float | int
):
prop = model.by_uuid("424efd65-eaa9-4220-b61b-fb3340dbc19a")

assert getattr(prop, attr).value == value


@pytest.mark.parametrize(
["value", "expected_xml"],
[(math.inf, "*"), (1, "1"), (0, "0")],
)
def test_literal_numeric_value_infinity_is_star(
model: capellambse.MelodyModel, value, expected_xml
):
prop = model.by_uuid("424efd65-eaa9-4220-b61b-fb3340dbc19a")
max_card = prop.max_card

max_card.value = value

assert max_card._element.get("value") == expected_xml


@pytest.mark.parametrize(
["attr", "value"],
[
Expand Down
4 changes: 3 additions & 1 deletion tests/test_xlayer_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ def test_complex_value(model: MelodyModel):
"uuid,expected_value,expected_cls",
[
pytest.param(
"1d24c16d-61ad-40b9-9ce0-80e72320e74f", 3, "LiteralNumericValue"
"1d24c16d-61ad-40b9-9ce0-80e72320e74f",
"3",
"LiteralNumericValue",
),
pytest.param(
"3c6d9df2-1229-4642-aede-a7ac129035c9",
Expand Down

0 comments on commit b3a0738

Please sign in to comment.