コード例 #1
0
ファイル: query_test.py プロジェクト: olethanh/gcloud-aio
    def test_from_repr_query_with_several_orders():
        orders = [
            PropertyOrder('property1', direction=Direction.ASCENDING),
            PropertyOrder('property2', direction=Direction.DESCENDING)
        ]
        original_query = Query(order=orders)

        data = {
            'kind': [],
            'order': [
                {
                    'property': {
                        'name': orders[0].prop
                    },
                    'direction': orders[0].direction
                },
                {
                    'property': {
                        'name': orders[1].prop
                    },
                    'direction': orders[1].direction
                }
            ]
        }

        output_query = Query.from_repr(data)

        assert output_query == original_query
コード例 #2
0
    def test_order_to_repr():
        property_name = 'my_prop'
        direction = Direction.DESCENDING
        order = PropertyOrder(property_name, direction)

        r = order.to_repr()

        assert r['property']['name'] == property_name
        assert r['direction'] == direction.value
コード例 #3
0
ファイル: query_test.py プロジェクト: olethanh/gcloud-aio
    def test_to_repr_query_with_several_orders():
        orders = [
            PropertyOrder('property1', direction=Direction.ASCENDING),
            PropertyOrder('property2', direction=Direction.DESCENDING)
        ]
        query = Query(order=orders)

        r = query.to_repr()

        assert len(r['order']) == 2
        assert r['order'][0] == orders[0].to_repr()
        assert r['order'][1] == orders[1].to_repr()
コード例 #4
0
    def test_order_from_repr(property_order):
        original_order = property_order
        data = {
            'property': {
                'name': original_order.prop
            },
            'direction': original_order.direction
        }

        output_order = PropertyOrder.from_repr(data)

        assert output_order == original_order
コード例 #5
0
 def test_order_defaults_to_ascending():
     assert PropertyOrder('prop_name').direction == Direction.ASCENDING
コード例 #6
0
 def property_order() -> PropertyOrder:
     return PropertyOrder(prop='prop_name', direction=Direction.DESCENDING)