Exemplo n.º 1
0
    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]
Exemplo n.º 2
0
 def test_returns_max_complex(self):
     p = Pinq(self.products)
     assert p.select(p.attr('price')).max() == 99.99
Exemplo n.º 3
0
 def test_returns_min_complex(self):
     p = Pinq(self.products)
     assert p.select(p.attr('price')).min() == 0.01
Exemplo n.º 4
0
 def test_returns_sum_complex(self):
     p = Pinq(self.products)
     assert p.select(p.attr('price')).sum() == 113
Exemplo n.º 5
0
 def test_returns_set_of_items_complex(self):
     p = Pinq(self.products)
     assert p.select(p.attr('category')).to_set() == {2, 4}
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
 def test_values_returned_are_from_select_clause(self):
     p = Pinq(self.products)
     assert p.select(p.attr('id')).to_list() == [1, 2, 3]