def test_with_dictonary(self): products = [ { 'id': 1, 'price': 13, 'category': 2 }, { 'id': 2, 'price': 99.99, 'category': 2 }, { 'id': 3, 'price': 0.01, 'category': 4 }, ] p = Pinq(products) assert p.select(p.item('price')).max() == 99.99 assert p.select(p.item('id')).to_list() == [1, 2, 3]
def test_returns_max_complex(self): p = Pinq(self.products) assert p.select(p.attr('price')).max() == 99.99
def test_returns_min_complex(self): p = Pinq(self.products) assert p.select(p.attr('price')).min() == 0.01
def test_returns_sum_complex(self): p = Pinq(self.products) assert p.select(p.attr('price')).sum() == 113
def test_returns_set_of_items_complex(self): p = Pinq(self.products) assert p.select(p.attr('category')).to_set() == {2, 4}
def test_multi_select(self): p = Pinq(self.products) expected = ["13.0", "99.99", "0.01"] assert p.select(p.attr('price')).select(str).to_list() == expected
def test_values_returned_are_from_select_clause(self): p = Pinq(self.products) assert p.select(p.attr('id')).to_list() == [1, 2, 3]