def test_group_by_flat(self): l = [i % 3 for i in range(12)] ez = EZDict() for item in l: ez.appender(item, item) self.assertEqual(ez, Query("$group_by").single(l))
def test_group_by_number(self): data = [[i, i] for i in range(10)] ez = EZDict() for item in data: ez.appender(item[0], item) self.assertEqual( ez, Query("$group_by(0)").single(data) )
def test_append(self): genders = EZDict() manual = {} for item in small_data: genders.appender(EZDict(item).gender, item) if item["gender"] in manual: manual[item["gender"]].append(item) else: manual[item["gender"]] = [item] self.assertEqual(manual, genders)
def test_group_by_nested(self): ez = EZDict() for item in small_data: ez.appender(round(EZDict(item).favoriteFruit.apple, 1), item) self.assertEqual(ez, Query("$group_by('favoriteFruit.apple.$round(1)')").single(small_data))