Exemplo n.º 1
0
 def test_good_002(self):
     scheme1 = {'id': int}
     scheme2 = {'name': str}
     scheme3 = {'email': str}
     s = Scheme(AnyOf(scheme1, scheme2, scheme3))
     s.validate({'id': 10}, [])
Exemplo n.º 2
0
        Optional('ordering_params'): [AnyOf('id', '-id')]
    }, **AUTHORIZED_REQUEST_AUTH_INFO)

GET_TRANSACTIONS_SELF_RESPONSE = AnyOf(
    dict(RESPONSE_STATUS_OK, **{
        'transactions': [TRANSACTION_INFO],
        'total': NonNegative(int),
    }), RESPONSE_STATUS_ERROR)

GET_TRANSACTIONS_REQUEST = dict(GET_TRANSACTIONS_SELF_REQUEST)
GET_TRANSACTIONS_REQUEST['filter_params'][Optional('user_id')] = int

GET_TRANSACTIONS_RESPONSE = GET_TRANSACTIONS_SELF_RESPONSE

protocol = [
    ApiCall('ping_request', Scheme(PING_REQUEST)),
    ApiCall('ping_response', Scheme(PING_RESPONSE)),

    # login user
    ApiCall('login_request', Scheme(LOGIN_REQUEST)),
    ApiCall('login_response', Scheme(LOGIN_RESPONSE)),

    # logout user
    ApiCall('logout_request', Scheme(LOGOUT_REQUEST)),
    ApiCall('logout_response', Scheme(LOGOUT_RESPONSE)),

    # currencies
    ApiCall('get_currencies_request', Scheme(GET_CURRENCIES_REQUEST)),
    ApiCall('get_currencies_response', Scheme(GET_CURRENCIES_RESPONSE)),
    ApiCall('get_used_currencies_request',
            Scheme(GET_USED_CURRENCIES_REQUEST)),
Exemplo n.º 3
0
 def test_good_001(self):
     s = Scheme({'id': int})
     s.validate({'id': 10}, [])
Exemplo n.º 4
0
        'paging_params': REQUEST_PAGING_PARAMS,
        Optional('ordering_params'): [AnyOf('id', '-id')]
    }, **AUTHORIZED_REQUEST_AUTH_INFO)

GET_USER_TARIFFS_RESPONSE = AnyOf(
    dict(
        RESPONSE_STATUS_OK, **{
            'user_tariffs': [{
                'user_id': int,
                'tariff_ids': [int]
            }],
            'total': NON_NEGATIVE_INT,
        }), RESPONSE_STATUS_ERROR)

protocol = [
    ApiCall('ping_request', Scheme(PING_REQUEST)),
    ApiCall('ping_response', Scheme(PING_RESPONSE)),

    # login user
    ApiCall('login_request', Scheme(LOGIN_REQUEST)),
    ApiCall('login_response', Scheme(LOGIN_RESPONSE)),

    # logout user
    ApiCall('logout_request', Scheme(LOGOUT_REQUEST)),
    ApiCall('logout_response', Scheme(LOGOUT_RESPONSE)),

    # tariffication object
    ApiCall('add_tariffication_object_request',
            Scheme(ADD_TARIFFICATION_OBJECT_REQUEST)),
    ApiCall('add_tariffication_object_response',
            Scheme(ADD_TARIFFICATION_OBJECT_RESPONSE)),