Skip to content

Commit

Permalink
AIP-72: Simplify test_get_templated_fields test (apache#44920)
Browse files Browse the repository at this point in the history
- Removed logic to do `ast.literal_eval`
- Added ids for each parameter so we can now see the following:

```
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[None] PASSED                                                                                                  [  6%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[list] PASSED                                                                                                  [ 12%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[empty_dict] PASSED                                                                                            [ 18%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[empty_tuple] PASSED                                                                                           [ 25%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[empty_set] PASSED                                                                                             [ 31%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[string] PASSED                                                                                                [ 37%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[dict] PASSED                                                                                                  [ 43%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[tuple] PASSED                                                                                                 [ 50%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[set] PASSED                                                                                                   [ 56%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_string] PASSED                                                                                      [ 62%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field10-2018-12-06] PASSED                                                                          [ 68%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[datetime] PASSED                                                                                              [ 75%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[class_with_custom_attributes] PASSED                                                                          [ 81%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[nested_class_with_custom_attributes] PASSED                                                                   [ 87%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[large_string] PASSED                                                                                          [ 93%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[large_object] PASSED                                                                                          [100%]
```

instead of the following large string:

```
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[None-None] PASSED                                                                                             [  6%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field1-expected_rendered_field1] PASSED                                                             [ 12%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field2-expected_rendered_field2] PASSED                                                             [ 18%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field3-()] PASSED                                                                                   [ 25%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field4-set()] PASSED                                                                                [ 31%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[test-string-test-string] PASSED                                                                               [ 37%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field6-expected_rendered_field6] PASSED                                                             [ 43%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field7-('foo', 'bar')] PASSED                                                                       [ 50%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field8-{'foo'}] PASSED                                                                              [ 56%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[{{ task.task_id }}-test] PASSED                                                                               [ 62%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field10-2018-12-06] PASSED                                                                          [ 68%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field11-2018-12-06 10:55:00+00:00] PASSED                                                           [ 75%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field12-ClassWithCustomAttributes({'att1': 'test', 'att2': '{{ task.task_id }}', 'template_fields': ['att1']})] PASSED [ 81%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field13-ClassWithCustomAttributes({'nested1': ClassWithCustomAttributes({'att1': 'test', 'att2': '{{ task.task_id }}', 'template_fields': ['att1']}), 'nested2': ClassWithCustomAttributes({'att3': '{{ task.task_id }}', 'att4': '{{ task.task_id }}', 'template_fields': ['att3']}), 'template_fields': ['nested1']})] PASSED [ 87%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'... ] PASSED [ 93%]
tests/models/test_renderedtifields.py::TestRenderedTaskInstanceFields::test_get_templated_fields[templated_field15-Truncated. You can change this behaviour in [core]max_templated_field_length. 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'... ] PASSED [100%]
```
  • Loading branch information
kaxil authored Dec 13, 2024
1 parent ff7e700 commit b69441d
Showing 1 changed file with 26 additions and 42 deletions.
68 changes: 26 additions & 42 deletions tests/models/test_renderedtifields.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from __future__ import annotations

import ast
import os
from collections import Counter
from datetime import date, timedelta
Expand Down Expand Up @@ -96,28 +95,29 @@ def teardown_method(self):
self.clean_db()

@pytest.mark.parametrize(
"templated_field, expected_rendered_field",
["templated_field", "expected_rendered_field"],
[
(None, None),
([], []),
({}, {}),
((), "()"),
(set(), "set()"),
("test-string", "test-string"),
({"foo": "bar"}, {"foo": "bar"}),
(("foo", "bar"), "('foo', 'bar')"),
({"foo", "bar"}, "{'foo', 'bar'}"),
("{{ task.task_id }}", "test"),
pytest.param(None, None, id="None"),
pytest.param([], [], id="list"),
pytest.param({}, {}, id="empty_dict"),
pytest.param((), "()", id="empty_tuple"),
pytest.param(set(), "set()", id="empty_set"),
pytest.param("test-string", "test-string", id="string"),
pytest.param({"foo": "bar"}, {"foo": "bar"}, id="dict"),
pytest.param(("foo", "bar"), "('foo', 'bar')", id="tuple"),
pytest.param({"foo"}, "{'foo'}", id="set"),
pytest.param("{{ task.task_id }}", "test", id="templated_string"),
(date(2018, 12, 6), "2018-12-06"),
(datetime(2018, 12, 6, 10, 55), "2018-12-06 10:55:00+00:00"),
(
pytest.param(datetime(2018, 12, 6, 10, 55), "2018-12-06 10:55:00+00:00", id="datetime"),
pytest.param(
ClassWithCustomAttributes(
att1="{{ task.task_id }}", att2="{{ task.task_id }}", template_fields=["att1"]
),
"ClassWithCustomAttributes({'att1': 'test', 'att2': '{{ task.task_id }}', "
"'template_fields': ['att1']})",
id="class_with_custom_attributes",
),
(
pytest.param(
ClassWithCustomAttributes(
nested1=ClassWithCustomAttributes(
att1="{{ task.task_id }}", att2="{{ task.task_id }}", template_fields=["att1"]
Expand All @@ -132,14 +132,17 @@ def teardown_method(self):
"'nested2': ClassWithCustomAttributes("
"{'att3': '{{ task.task_id }}', 'att4': '{{ task.task_id }}', 'template_fields': ['att3']}), "
"'template_fields': ['nested1']})",
id="nested_class_with_custom_attributes",
),
(
pytest.param(
"a" * 5000,
f"Truncated. You can change this behaviour in [core]max_templated_field_length. {('a'*5000)[:max_length-79]!r}... ",
id="large_string",
),
(
pytest.param(
LargeStrObject(),
f"Truncated. You can change this behaviour in [core]max_templated_field_length. {str(LargeStrObject())[:max_length-79]!r}... ",
id="large_object",
),
],
)
Expand All @@ -163,35 +166,16 @@ def test_get_templated_fields(self, templated_field, expected_rendered_field, da
assert ti.dag_id == rtif.dag_id
assert ti.task_id == rtif.task_id
assert ti.run_id == rtif.run_id
if type(templated_field) is set:
# the output order of a set is non-deterministic and can change per process.
# this validation can fail if that happens before stringification, so we convert to set and compare.
assert ast.literal_eval(expected_rendered_field) == ast.literal_eval(
rtif.rendered_fields.get("bash_command")
)
else:
assert expected_rendered_field == rtif.rendered_fields.get("bash_command")
assert expected_rendered_field == rtif.rendered_fields.get("bash_command")

session.add(rtif)
session.flush()

if type(templated_field) is set:
# the output order of a set is non-deterministic and can change per process.
# this validation can fail if that happens before stringification, so we convert to set and compare.
expected = RTIF.get_templated_fields(ti=ti, session=session)
expected["bash_command"] = ast.literal_eval(expected["bash_command"])
actual = {
"bash_command": ast.literal_eval(expected_rendered_field),
"env": None,
"cwd": None,
}
assert expected == actual
else:
assert RTIF.get_templated_fields(ti=ti, session=session) == {
"bash_command": expected_rendered_field,
"env": None,
"cwd": None,
}
assert RTIF.get_templated_fields(ti=ti, session=session) == {
"bash_command": expected_rendered_field,
"env": None,
"cwd": None,
}
# Test the else part of get_templated_fields
# i.e. for the TIs that are not stored in RTIF table
# Fetching them will return None
Expand Down

0 comments on commit b69441d

Please sign in to comment.