def test_multifield_descend(self): """Test that we can format dictionaries.""" formatter = MultiFieldDescend(['city', 'state'], NoopFormatter()) self.assertEqual(["Indy", "IN"], formatter.format({ "city": "Indy", "state": "IN" }))
def test_multifield_descend_missing_key(self): """Test that we can handle missing dictionary keys.""" formatter = MultiFieldDescend(['city', 'state'], NoopFormatter()) self.assertEqual(["Indy", None], formatter.format({"city": "Indy"}))
def test_multifield_descend_non_dict(self): """Test that we can handle non-dicts.""" formatter = MultiFieldDescend(['city', 'state'], StringFormatter()) self.assertEqual("[1]", formatter.format(1))