Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions tests/schema/__snapshots__/test_schema.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -5090,6 +5090,48 @@
}),
})
# ---
# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_error]
'''
ERROR: Need 'SPEC_1' has schema violations:
Severity: violation
Need path: IMPL_1 > links > SPEC_1
Schema path: [0] > validate > network > links > items > local > unevaluatedProperties
Schema message: Unevaluated properties are not allowed ('asil' was unexpected) [sn_schema_violation.network_local_fail]

'''
# ---
# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_error].1
dict({
'validated_needs_count': 2,
'validation_warnings': dict({
'IMPL_1': list([
dict({
'children': list([
]),
'details': dict({
'need_path': 'IMPL_1 > links > SPEC_1',
'schema_path': '[0] > validate > network > links > items > local > unevaluatedProperties',
'severity': 'violation',
'validation_msg': "Unevaluated properties are not allowed ('asil' was unexpected)",
}),
'log_lvl': 'error',
'subtype': 'network_local_fail',
'type': 'sn_schema_violation',
}),
]),
}),
})
# ---
# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_ok]
''
# ---
# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_ok].1
dict({
'validated_needs_count': 2,
'validation_warnings': dict({
}),
})
# ---
# name: test_schemas[schema/fixtures/network-no_error_empty_links]
'''
ERROR: Need 'IMPL_SAFE' has schema violations:
Expand Down
70 changes: 70 additions & 0 deletions tests/schema/fixtures/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,76 @@ max_network_levels:
type:
const: spec

network_local_unevaluated_reduced_ok:
# The network-local schema uses ``unevaluatedProperties``, whose semantics are only
# meaningful after ``reduce_need()`` strips the fields the schema does not reference.
# SN applies that same reduction inside the network path (``_validate_need_local``)
# as for top-level local validation, so the linked spec — reduced to just
# ``{type: spec}`` — validates cleanly and ``items`` passes with no warning.
conf: |
extensions = ["sphinx_needs"]
needs_from_toml = "ubproject.toml"
needs_schema_definitions_from_json = "schemas.json"
ubproject: |
[needs.fields.asil]
nullable = true
rst: |
.. spec:: title
:id: SPEC_1

.. impl:: title
:id: IMPL_1
:links: SPEC_1
schemas:
$defs: []
schemas:
- select:
properties:
type: {const: "impl"}
validate:
network:
links:
items:
local:
properties:
type: {const: spec}
unevaluatedProperties: false

network_local_unevaluated_reduced_error:
# Same as ``network_local_unevaluated_reduced_ok`` but the linked spec sets an extra
# field (``asil``) that the network-local schema does not reference. ``reduce_need()``
# keeps actively-set extra fields, so ``unevaluatedProperties: false`` still fails on
# it — confirming reduction matches the top-level path without masking real violations.
conf: |
extensions = ["sphinx_needs"]
needs_from_toml = "ubproject.toml"
needs_schema_definitions_from_json = "schemas.json"
ubproject: |
[needs.fields.asil]
nullable = true
rst: |
.. spec:: title
:id: SPEC_1
:asil: QM

.. impl:: title
:id: IMPL_1
:links: SPEC_1
schemas:
$defs: []
schemas:
- select:
properties:
type: {const: "impl"}
validate:
network:
links:
items:
local:
properties:
type: {const: spec}
unevaluatedProperties: false

link_name_contains:
conf: |
extensions = ["sphinx_needs"]
Expand Down
Loading