feat: working TOM agent
This commit is contained in:
207
tests/test_teams.py
Normal file
207
tests/test_teams.py
Normal file
@@ -0,0 +1,207 @@
|
||||
"""Teams and how they work together: Team Topologies in the operating model graph."""
|
||||
|
||||
import pytest
|
||||
|
||||
from app.operating_model import graph as model
|
||||
from app.operating_model import guide
|
||||
from app.operating_model.names import GRAPH_FILE
|
||||
from tests.support import (
|
||||
CARD,
|
||||
CATALOGUE,
|
||||
GRAPH,
|
||||
SPEC,
|
||||
as_file,
|
||||
graph,
|
||||
scope_data,
|
||||
upstream,
|
||||
)
|
||||
|
||||
check = model.check(CARD)
|
||||
|
||||
|
||||
def with_teams() -> dict:
|
||||
"""The test model, with the provider's Roles in a platform team that the
|
||||
customer's platform owner consumes as a service."""
|
||||
teamed = graph()
|
||||
teamed["teams"] = [
|
||||
{
|
||||
"id": "T-1",
|
||||
"party": "P-1",
|
||||
"name": "Northwind product squad",
|
||||
"type": "stream_aligned",
|
||||
},
|
||||
{
|
||||
"id": "T-2",
|
||||
"party": "P-2",
|
||||
"name": "Platform team",
|
||||
"type": "platform",
|
||||
"purpose": "Runs the landing zone as a product.",
|
||||
},
|
||||
{"id": "T-3", "party": "P-2", "name": "Adoption", "type": "enabling"},
|
||||
]
|
||||
teamed["roles"][0]["team"] = "T-1"
|
||||
teamed["roles"][1]["team"] = "T-2"
|
||||
teamed["roles"][2]["team"] = "T-2"
|
||||
teamed["interactions"] = [
|
||||
{
|
||||
"id": "I-1",
|
||||
"from": "T-1",
|
||||
"to": "T-2",
|
||||
"mode": "x_as_a_service",
|
||||
"purpose": "Environments through the self-service portal.",
|
||||
},
|
||||
{"id": "I-2", "from": "T-3", "to": "T-1", "mode": "facilitating"},
|
||||
{
|
||||
"id": "I-3",
|
||||
"from": "T-1",
|
||||
"to": "T-2",
|
||||
"mode": "collaboration",
|
||||
"until": "the first workload is live",
|
||||
},
|
||||
]
|
||||
return teamed
|
||||
|
||||
|
||||
def faults(changed) -> list[str]:
|
||||
return check(as_file(GRAPH_FILE, changed), upstream())
|
||||
|
||||
|
||||
def test_teams_are_optional():
|
||||
assert faults(GRAPH) == []
|
||||
|
||||
|
||||
def test_teams_of_the_four_kinds_working_in_the_three_modes_are_accepted():
|
||||
assert faults(with_teams()) == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("change", "problem"),
|
||||
[
|
||||
(
|
||||
lambda g: g["teams"][1].update(type="squad"),
|
||||
"Team T-2: type must be one of stream_aligned, platform",
|
||||
),
|
||||
(
|
||||
lambda g: g["teams"][1].update(party="P-9"),
|
||||
"Team T-2 is in P-9, which is not a Party",
|
||||
),
|
||||
(
|
||||
lambda g: g["roles"][1].update(team="T-9"),
|
||||
"Role R-2 is in T-9, which is not a Team",
|
||||
),
|
||||
(
|
||||
lambda g: g["roles"][0].update(team="T-2"),
|
||||
"Role R-1 is in P-1, and its team T-2 is in P-2",
|
||||
),
|
||||
(
|
||||
lambda g: g["interactions"][0].update(mode="ticket"),
|
||||
"Interaction I-1: mode must be one of",
|
||||
),
|
||||
(
|
||||
lambda g: g["interactions"][0].update(to="T-9"),
|
||||
"Interaction I-1: to T-9 is not a Team",
|
||||
),
|
||||
(
|
||||
lambda g: g["interactions"][0].update(to="T-1"),
|
||||
"Interaction I-1 is between a team and itself",
|
||||
),
|
||||
(
|
||||
lambda g: g["interactions"][2].pop("until"),
|
||||
"Interaction I-3 is a collaboration and does not say when it ends",
|
||||
),
|
||||
(lambda g: g["teams"][0].pop("type"), "(T-1) needs type"),
|
||||
],
|
||||
)
|
||||
def test_teams_that_do_not_hold_together_are_refused(change, problem):
|
||||
changed = with_teams()
|
||||
change(changed)
|
||||
|
||||
found = faults(changed)
|
||||
|
||||
assert any(problem in fault for fault in found), found
|
||||
|
||||
|
||||
def test_a_check_may_be_on_a_team_or_an_interaction():
|
||||
changed = with_teams()
|
||||
changed["checks"].append(
|
||||
{
|
||||
"id": "OC-9",
|
||||
"on": "I-1",
|
||||
"source": "OR-2",
|
||||
"condition": "Every environment request is met through the portal, with no ticket.",
|
||||
}
|
||||
)
|
||||
|
||||
assert faults(changed) == []
|
||||
|
||||
|
||||
def test_the_chart_draws_each_team_inside_its_party_and_how_teams_work_together():
|
||||
chart = model.render_organisation(with_teams())
|
||||
|
||||
assert ' subgraph T_2["Platform team (platform team)"]' in chart
|
||||
assert ' R_2["Platform SRE<br/>PL, senior, 24x7"]' in chart
|
||||
assert ' T_1 -- "x-as-a-service" --> T_2' in chart
|
||||
assert ' T_1 -- "collaboration until the first workload is live" --> T_2' in chart
|
||||
|
||||
|
||||
def test_the_chart_without_teams_is_as_it_was():
|
||||
chart = model.render_organisation(GRAPH)
|
||||
|
||||
assert " R_2[" in chart
|
||||
assert " -- " not in chart
|
||||
|
||||
|
||||
def test_the_guide_shows_the_teams_and_their_interactions():
|
||||
built = upstream(model=with_teams())
|
||||
text = guide.who_does_what(built, CATALOGUE)
|
||||
|
||||
assert (
|
||||
"| Platform team | platform | Managed service provider | Platform SRE, Service manager | Runs the landing zone as a product. |"
|
||||
in text
|
||||
)
|
||||
assert (
|
||||
"| Northwind product squad | Platform team | x-as-a-service | | Environments through the self-service portal. |"
|
||||
in text
|
||||
)
|
||||
# The matrix still follows.
|
||||
assert "| Incident management (C-1) |" in text
|
||||
|
||||
|
||||
def test_a_platform_foundation_is_proposed_the_platform_and_measurement_capabilities():
|
||||
proposed = CATALOGUE.applicable(scope_data(SPEC))
|
||||
|
||||
assert {
|
||||
"platform-product-management",
|
||||
"self-service-and-golden-paths",
|
||||
"enablement",
|
||||
"delivery-and-developer-experience-measurement",
|
||||
} <= set(proposed)
|
||||
|
||||
|
||||
def test_a_workload_is_not_proposed_the_platform_capabilities():
|
||||
workload = SPEC.replace("kind: platform_foundation", "kind: workload")
|
||||
|
||||
proposed = CATALOGUE.applicable(scope_data(workload))
|
||||
|
||||
assert "platform-product-management" not in proposed
|
||||
assert "delivery-and-developer-experience-measurement" in proposed
|
||||
|
||||
|
||||
def test_measurement_cites_three_layers_and_none_alone():
|
||||
entry = CATALOGUE.entries["delivery-and-developer-experience-measurement"]
|
||||
|
||||
assert [s["framework"] for s in entry.sources] == [
|
||||
"dora-metrics",
|
||||
"space-framework",
|
||||
"devex-framework",
|
||||
]
|
||||
assert len(entry.typical_checks) == 3
|
||||
|
||||
|
||||
def test_the_socio_technical_frameworks_are_registered():
|
||||
names = {key: value["name"] for key, value in CATALOGUE.frameworks.items()}
|
||||
|
||||
assert names["team-topologies"].startswith("Team Topologies")
|
||||
assert "platform as a product" in names["platform-as-a-product"]
|
||||
assert names["space-framework"] == "The SPACE of Developer Productivity"
|
||||
assert names["devex-framework"].startswith("DevEx")
|
||||
Reference in New Issue
Block a user