Esempio n. 1
0
    def test_input__query_params(self):

        s = Signature(method='get',
                      path='/cards/',
                      path_parameters=[],
                      authorization_required=True,
                      request_query=MockInterface(name='ReadCardRequestQuery'),
                      request_body=MockInterface(is_empty=True))

        assert s.input == 'params: X.ReadCardRequestQuery'
Esempio n. 2
0
    def test_call_args_without_path__body_params(self):

        s = Signature(method='post',
                      path='/cards/',
                      path_parameters=[],
                      authorization_required=True,
                      request_query=MockInterface(is_empty=True),
                      request_body=MockInterface(name='ReadCardRequestBody'))

        assert s.call_args_without_path == 'body'
Esempio n. 3
0
    def test_call_args_without_path__query_params(self):

        s = Signature(method='get',
                      path='/paths/',
                      path_parameters=[],
                      authorization_required=True,
                      request_query=MockInterface(name='ReadPathRequestQuery'),
                      request_body=MockInterface(is_empty=True))

        assert s.call_args_without_path == 'params'
Esempio n. 4
0
    def test_call_args_without_path__nothing(self):

        s = Signature(method='get',
                      path='/cards',
                      path_parameters=[],
                      authorization_required=True,
                      request_query=MockInterface(is_empty=True),
                      request_body=MockInterface(is_empty=True))

        assert s.call_args_without_path == ''
Esempio n. 5
0
    def test_call_args__path_parameters(self):

        # -- single parameter
        s = Signature(method='get',
                      path='/cards/{card_id}',
                      path_parameters=[{
                          'name': 'card_id',
                          'type': int
                      }],
                      authorization_required=True,
                      request_query=MockInterface(is_empty=True),
                      request_body=MockInterface(is_empty=True))

        assert s.call_args == (
            '`/cards/${cardId}`, { authorizationRequired: true }')

        # -- multiple parameters
        s = Signature(method='get',
                      path='/cards/{card_id}/{name}/users/{user_id}',
                      path_parameters=[
                          {
                              'name': 'card_id',
                              'type': int
                          },
                          {
                              'name': 'user_id',
                              'type': str
                          },
                          {
                              'name': 'name',
                              'type': str
                          },
                      ],
                      authorization_required=True,
                      request_query=MockInterface(is_empty=True),
                      request_body=MockInterface(is_empty=True))

        assert s.call_args == ('`/cards/${cardId}/${name}/users/${userId}`, '
                               '{ authorizationRequired: true }')
Esempio n. 6
0
    def test_input__path_parameters(self):

        # -- single parameter
        s = Signature(method='get',
                      path='/cards/{card_id}',
                      path_parameters=[{
                          'name': 'card_id',
                          'type': int
                      }],
                      authorization_required=True,
                      request_query=MockInterface(is_empty=True),
                      request_body=MockInterface(is_empty=True))

        assert s.input == 'cardId: number'

        # -- multiple parameters
        s = Signature(method='get',
                      path='/cards/{card_id}',
                      path_parameters=[
                          {
                              'name': 'card_id',
                              'type': int
                          },
                          {
                              'name': 'user_id',
                              'type': str
                          },
                          {
                              'name': 'name',
                              'type': str
                          },
                      ],
                      authorization_required=True,
                      request_query=MockInterface(is_empty=True),
                      request_body=MockInterface(is_empty=True))

        assert s.input == 'cardId: number, userId: string, name: string'
Esempio n. 7
0
    def test_call_args__bulk_read_field_and_path_parameters_and_query_params(
            self):  # noqa

        s = Signature(method='get',
                      path='/cards/{card_id}',
                      path_parameters=[
                          {
                              'name': 'card_id',
                              'type': int
                          },
                      ],
                      authorization_required=True,
                      request_query=MockInterface(is_empty=False),
                      request_body=MockInterface(is_empty=True),
                      bulk_read_field='cards')

        assert (s.call_args ==
                '`/cards/${cardId}`, { params, authorizationRequired: true }')
Esempio n. 8
0
    def test_call_args_without_path__path_parameters_and_body_params(self):

        s = Signature(method='post',
                      path='/cards/{card_id}/users/{user_id}',
                      path_parameters=[
                          {
                              'name': 'card_id',
                              'type': int
                          },
                          {
                              'name': 'user_id',
                              'type': str
                          },
                      ],
                      authorization_required=True,
                      request_query=MockInterface(is_empty=True),
                      request_body=MockInterface(name='ReadCardRequestBody'))

        assert s.call_args_without_path == 'cardId, userId, body'
Esempio n. 9
0
    def test_call_args_without_path__path_parameters_and_query_params(self):

        s = Signature(method='get',
                      path='/paths/{path_id}/users/{user_id}',
                      path_parameters=[
                          {
                              'name': 'path_id',
                              'type': int
                          },
                          {
                              'name': 'user_id',
                              'type': str
                          },
                      ],
                      authorization_required=True,
                      request_query=MockInterface(name='ReadPathRequestQuery'),
                      request_body=MockInterface(is_empty=True))

        assert s.call_args_without_path == 'pathId, userId, params'
Esempio n. 10
0
    def test_input__path_parameters_and_query_params(self):

        s = Signature(method='get',
                      path='/cards/{card_id}/users/{user_id}',
                      path_parameters=[
                          {
                              'name': 'card_id',
                              'type': int
                          },
                          {
                              'name': 'user_id',
                              'type': str
                          },
                      ],
                      authorization_required=True,
                      request_query=MockInterface(name='ReadCardRequestQuery'),
                      request_body=MockInterface(is_empty=True))

        assert s.input == (
            'cardId: number, userId: string, params: X.ReadCardRequestQuery')
Esempio n. 11
0
    def test_call_args__path_parameters_and_no_body(self):

        s = Signature(method='post',
                      path='/cards/{card_id}/users/{user_id}',
                      path_parameters=[
                          {
                              'name': 'card_id',
                              'type': int
                          },
                          {
                              'name': 'user_id',
                              'type': str
                          },
                      ],
                      authorization_required=False,
                      request_query=MockInterface(is_empty=True),
                      request_body=MockInterface(is_empty=True))

        assert s.call_args == ('`/cards/${cardId}/users/${userId}`, '
                               '{}, { authorizationRequired: false }')