Skip to content

Added Tests for default values being null - #5767

Merged
herin049 merged 5 commits into
open-telemetry:mainfrom
SaisakthiM:main
Oct 26, 2026
Merged

herin049 merged 5 commits into
open-telemetry:mainfrom
SaisakthiM:main

Conversation

@SaisakthiM

@SaisakthiM SaisakthiM commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds a test for default values being out of range and being null as a regression test

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Test
❯ pytest codegen/opentelemetry-codegen-json/tests/test_default_values.py -v
=============================================================================== test session starts ================================================================================
platform linux -- Python 3.14.7, pytest-9.0.3, pluggy-1.6.0 -- /home/saisakthi/Coding-Project/General Programming Skills/Git/opentelemetry-python/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/saisakthi/Coding-Project/General Programming Skills/Git/opentelemetry-python
configfile: pyproject.toml
plugins: platformdirs-4.13.0
collected 31 items                                                                                                                                                                 

codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_known_types[1-0.0] PASSED                                                            [  3%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_known_types[2-0.0] PASSED                                                            [  6%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_known_types[3-0] PASSED                                                              [  9%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_known_types[13-0] PASSED                                                             [ 12%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_known_types[18-0] PASSED                                                             [ 16%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_known_types[8-False] PASSED                                                          [ 19%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_known_types[9-""] PASSED                                                             [ 22%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_known_types[12-b""] PASSED                                                           [ 25%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_valid_types_without_default[10] PASSED                                               [ 29%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_valid_types_without_default[11] PASSED                                               [ 32%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_valid_types_without_default[14] PASSED                                               [ 35%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_out_of_range[0] PASSED                                                               [ 38%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_out_of_range[-1] PASSED                                                              [ 41%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_out_of_range[999] PASSED                                                             [ 45%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_get_default_value_out_of_range[2147483648] PASSED                                                      [ 48%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_every_mapped_type_has_a_default PASSED                                                                 [ 51%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[1] PASSED                                                              [ 54%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[2] PASSED                                                              [ 58%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[3] PASSED                                                              [ 61%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[4] PASSED                                                              [ 64%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[5] PASSED                                                              [ 67%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[6] PASSED                                                              [ 70%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[7] PASSED                                                              [ 74%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[8] PASSED                                                              [ 77%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[9] PASSED                                                              [ 80%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[12] PASSED                                                             [ 83%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[13] PASSED                                                             [ 87%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[15] PASSED                                                             [ 90%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[16] PASSED                                                             [ 93%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[17] PASSED                                                             [ 96%]
codegen/opentelemetry-codegen-json/tests/test_default_values.py::test_default_is_valid_python_literal[18] PASSED                                                             [100%]

================================================================================ 31 passed in 0.45s ================================================================================

Issue and Doubt

Is the get_default_value intentionally defaulted to None, if that's not the case we can raise a Index or a ValueError and change the test
I wanted to raise a issue but i just asked it here

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • [ ] Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@SaisakthiM
SaisakthiM requested a review from a team as a code owner October 11, 2026 04:29
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: SaisakthiM / name: SaisakthiM (4b73f19)

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-26 21:01 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Comment thread codegen/opentelemetry-codegen-json/tests/test_default_values.py Outdated
Comment thread codegen/opentelemetry-codegen-json/tests/test_default_values.py Outdated
@SaisakthiM
SaisakthiM requested a review from herin049 October 15, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The test-only changes match existing behavior, and static review identified no blocking issues.

0 open findings

What changed in this PR

Adds regression coverage for default-value handling in the JSON code generator without changing production behavior.

Changes:

  • Covers additional scalar defaults and "None" fallbacks for unmapped and out-of-range types.
  • Checks mapping consistency and validates generated default literals against their Python types.
File Description
codegen/​opentelemetry-codegen-json/​tests/​test_types.py Expands default-value tests and simplifies descriptor references.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The test-only changes match existing behavior, with no blocking issues identified; tests were not executed during this review.

No open issues 🎉

Review effort: Balanced

@herin049 herin049 added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Oct 26, 2026
@herin049
herin049 enabled auto-merge October 26, 2026 20:36
@herin049
herin049 added this pull request to the merge queue Oct 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 26, 2026
@herin049
herin049 added this pull request to the merge queue Oct 26, 2026
Merged via the queue into open-telemetry:main with commit 087ab86 Oct 26, 2026
580 of 581 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants