Skip to content

Conversation

@nailo2c
Copy link
Contributor

@nailo2c nailo2c commented Jun 5, 2025

Related: #35127

I'm trying to improve the code coverage for serialization. If someone could take a look, I’d really appreciate it. :)

File Coverage (before) Coverage (after)
airflow-core/src/airflow/serialization/dag_dependency.py 95% 95%
airflow-core/src/airflow/serialization/enums.py 100% 100%
airflow-core/src/airflow/serialization/helpers.py 94% 94%
airflow-core/src/airflow/serialization/json_schema.py 81% 88%
airflow-core/src/airflow/serialization/serde.py 86% 95%
airflow-core/src/airflow/serialization/serialized_objects.py 86% 90%
airflow-core/src/airflow/serialization/serializers/bignum.py 80% 100%
airflow-core/src/airflow/serialization/serializers/builtin.py 82% 100%
airflow-core/src/airflow/serialization/serializers/datetime.py 93% 93%
airflow-core/src/airflow/serialization/serializers/deltalake.py 87% 100%
airflow-core/src/airflow/serialization/serializers/iceberg.py 21% 21%
airflow-core/src/airflow/serialization/serializers/kubernetes.py 60% 87%
airflow-core/src/airflow/serialization/serializers/numpy.py 56% 94%
airflow-core/src/airflow/serialization/serializers/pandas.py 81% 100%
airflow-core/src/airflow/serialization/serializers/timezone.py 73% 100%
Total 85% 90%

Btw, I found that the tests for iceberg.py only work when pyiceberg >= 2.0.0.

However, the pyiceberg version in my Breeze shell is 0.9.1, which is why the coverage is low. Does anyone know why the minimum version is set to 2.0.0?

def test_iceberg(self):
    pytest.importorskip("pyiceberg", minversion="2.0.0")

@shahar1 shahar1 requested a review from Copilot June 6, 2025 17:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR increases test coverage across various serialization modules by adding new unit tests for schema validation, callback request types, asset decoding, data intervals, timezone encoding, and multiple serializer implementations.

  • Added schema validation tests for BaseSerialization.validate_schema
  • Expanded serialization/deserialization tests for callback requests, assets, and datetime-related types
  • Broadened serializer tests (bignum, numpy, pandas, deltalake, kubernetes, timezone, JSON schema loader)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/unit/serialization/test_serialized_objects.py Added tests for schema validation, callback requests, data intervals, hash, asset decoding, and timezone encoding
tests/unit/serialization/serializers/test_serializers.py Added serializer tests for bignum, numpy, pandas, deltalake, kubernetes, timezone, and JSON schema loader
Comments suppressed due to low confidence (2)

airflow-core/tests/unit/serialization/test_serialized_objects.py:329

  • The new DeadlineAlert case uses None for the expected type and comparator, so it isn’t actually verifying serialization/deserialization behavior. Add the appropriate DAT.DEADLINE_ALERT constant and a comparator (e.g., check reference, interval, and callback) to fully test this path.
(            DeadlineAlert( ... ),            None,            None,        ),

airflow-core/tests/unit/serialization/serializers/test_serializers.py:498

  • The phrase "does not exists" is grammatically incorrect. Update the error message to "Schema file schema.json does not exist" and adjust the test accordingly.
assert "Schema file schema.json does not exists" in str(ctx.value)

Copy link
Contributor

@shahar1 shahar1 left a comment

Choose a reason for hiding this comment

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

Well done! Increasing Airflow's coverage is indeed quite important.

As a general rule of thumb, when there's no dependency between assertions - I think that it's better to seperate assertions to multiple tests (which could also be parametrized) - it will make it easier to detect exactly what assertions went wrong. Otherwise, when failing upon the first assertion within a test - the assertions below won't be checked.

@nailo2c
Copy link
Contributor Author

nailo2c commented Jun 6, 2025

Thanks for the review, good point about splitting the assertions.
I'll refactor the test and push an update later :)

@nailo2c
Copy link
Contributor Author

nailo2c commented Jun 10, 2025

Hi @shahar1, I’ve refactored the tests per your suggestion, thanks! Let me know what you think 🙏

@shahar1 shahar1 self-requested a review June 12, 2025 12:07
@nailo2c
Copy link
Contributor Author

nailo2c commented Jun 13, 2025

Fixed, thanks for reviewing! If there's anything that needs improvement, please let me know 💪

Copy link
Contributor

@shahar1 shahar1 left a comment

Choose a reason for hiding this comment

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

Great job! Thanks for your contribution :)

@shahar1 shahar1 merged commit f72d25a into apache:main Jun 14, 2025
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants