-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
repo ci/cdTesting and continuous integration for dbt-core + adapter pluginsTesting and continuous integration for dbt-core + adapter pluginstech_debtBehind-the-scenes changes, with little direct impact on end-user functionalityBehind-the-scenes changes, with little direct impact on end-user functionality
Description
Let's extend this test, so it validates serialization to proto (and thereby our proto schema definitions) in addition to JSON:
dbt-core/tests/unit/test_events.py
Lines 391 to 417 in b2ea2b8
| class TestEventJSONSerialization: | |
| # attempts to test that every event is serializable to json. | |
| # event types that take `Any` are not possible to test in this way since some will serialize | |
| # just fine and others won't. | |
| def test_all_serializable(self): | |
| all_non_abstract_events = set( | |
| get_all_subclasses(BaseEvent), | |
| ) | |
| all_event_values_list = list(map(lambda x: x.__class__, sample_values)) | |
| diff = all_non_abstract_events.difference(set(all_event_values_list)) | |
| assert ( | |
| not diff | |
| ), f"test is missing concrete values in `sample_values`. Please add the values for the aforementioned event classes" | |
| # make sure everything in the list is a value not a type | |
| for event in sample_values: | |
| assert type(event) != type | |
| # if we have everything we need to test, try to serialize everything | |
| for event in sample_values: | |
| msg = msg_from_base_event(event) | |
| msg_dict = msg_to_dict(msg) | |
| try: | |
| msg_json = msg_to_json(msg) | |
| except Exception as e: | |
| raise Exception(f"{event} is not serializable to json. Originating exception: {e}") |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
repo ci/cdTesting and continuous integration for dbt-core + adapter pluginsTesting and continuous integration for dbt-core + adapter pluginstech_debtBehind-the-scenes changes, with little direct impact on end-user functionalityBehind-the-scenes changes, with little direct impact on end-user functionality