Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add tests for _flatten_dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Feb 3, 2023
1 parent d5651e5 commit aed4d21
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/push/test_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@
from tests.test_utils.event_injection import create_event, inject_member_event


class FlattenDictTestCase(unittest.TestCase):
def test_simple(self) -> None:
"""Test a dictionary that isn't modified."""
input = {"foo": "abc"}
self.assertEqual(input, _flatten_dict(input))

def test_nested(self) -> None:
"""Nested dictionaries become dotted paths."""
input = {"foo": {"bar": "abc"}}
self.assertEqual({"foo.bar": "abc"}, _flatten_dict(input))

def test_non_string(self) -> None:
"""Booleans, ints, and nulls should be kept while other items are dropped."""
input: Dict[str, Any] = {
"foo": True,
"bar": 1,
"baz": None,
"fuzz": [],
"boo": {},
}
self.assertEqual({"foo": True, "bar": 1, "baz": None}, _flatten_dict(input))


class PushRuleEvaluatorTestCase(unittest.TestCase):
def _get_evaluator(
self,
Expand Down

0 comments on commit aed4d21

Please sign in to comment.