def test_validate_pagination_params_no_content(self):
     with self.app.test_request_context('/?limit=10&start=0', method='GET'):
         with patch.object(Interactions, 'list', return_value=[]):
             response = paginate(
                 request, DEFAULT_ACCOUNTS_TABLE, 'accounts'
             )
             self.assertEqual(response.status_code, client.NO_CONTENT)
    def get(self):
        """
        Get the user's registered webhooks
        """
        account_id = lookup_account_id(request.headers['username'])

        return paginate(request, DEFAULT_REGISTRATIONS_TABLE, 'registrations',
                        filters={'account_id': account_id})
Example #3
0
 def test_validate_pagination_params_wth_next_marker(self):
     with self.app.test_request_context('/?limit=1&start=0', method='GET'):
         with patch.object(Interactions,
                           'list',
                           return_value=self.returned_records):
             response = paginate(request, DEFAULT_ACCOUNTS_TABLE,
                                 'accounts')
             self.assertTrue('next_start' in str(response.data))
             self.assertEqual(response.status_code, client.OK)
 def test_validate_pagination_params_wth_next_marker(self):
     with self.app.test_request_context('/?limit=1&start=0', method='GET'):
         with patch.object(Interactions, 'list',
                           return_value=self.returned_records):
             response = paginate(
                 request, DEFAULT_ACCOUNTS_TABLE, 'accounts'
             )
             self.assertTrue('next_start' in str(response.data))
             self.assertEqual(response.status_code, client.OK)
Example #5
0
    def get(self):
        """
        Get the user's registered webhooks
        """
        account_id = lookup_account_id(request.headers['username'])

        return paginate(request,
                        DEFAULT_REGISTRATIONS_TABLE,
                        'registrations',
                        filters={'account_id': account_id})
Example #6
0
    def get(self):
        """
        Get the user's webhook subscriptions
        """
        try:
            account_id = lookup_account_id(request.headers['username'])
        # pylint: disable=W0703
        except Exception:
            return make_response(
                jsonify({'Error': 'Invalid username or account'}),
                client.BAD_REQUEST)

        return paginate(request, DEFAULT_SUBSCRIPTIONS_TABLE, 'subscriptions',
                        filters={'account_id': account_id})
Example #7
0
    def get(self):
        """
        Get the user's webhook subscriptions
        """
        try:
            account_id = lookup_account_id(request.headers['username'])
        # pylint: disable=W0703
        except Exception:
            return make_response(
                jsonify({'Error': 'Invalid username or account'}),
                client.BAD_REQUEST)

        return paginate(request,
                        DEFAULT_SUBSCRIPTIONS_TABLE,
                        'subscriptions',
                        filters={'account_id': account_id})
Example #8
0
 def get(self):
     """
     Get a listing of accounts (paginated if need be)
     """
     return paginate(request, DEFAULT_ACCOUNTS_TABLE, 'accounts')
Example #9
0
 def get(self):
     """
     Get a listing of Registrations (paginated if need be)
     """
     return paginate(request, DEFAULT_REGISTRATIONS_TABLE, 'registrations')
Example #10
0
 def get(self):
     """
     Get a listing of triggered webhooks (paginated if need be)
     """
     return paginate(request, DEFAULT_TRIGGERED_TABLE, 'triggered_webhooks')
Example #11
0
 def get(self):
     """
     Get a listing of accounts (paginated if need be)
     """
     return paginate(request, DEFAULT_ACCOUNTS_TABLE, 'accounts')
Example #12
0
 def test_validate_pagination_params_no_content(self):
     with self.app.test_request_context('/?limit=10&start=0', method='GET'):
         with patch.object(Interactions, 'list', return_value=[]):
             response = paginate(request, DEFAULT_ACCOUNTS_TABLE,
                                 'accounts')
             self.assertEqual(response.status_code, client.NO_CONTENT)
Example #13
0
 def get(self):
     """
     Get a listing of subscriptions (paginated if need be)
     """
     return paginate(request, DEFAULT_SUBSCRIPTIONS_TABLE, 'subscriptions')
Example #14
0
 def get(self):
     """
     Get a listing of triggered webhooks (paginated if need be)
     """
     return paginate(request, DEFAULT_TRIGGERED_TABLE, 'triggered_webhooks')
Example #15
0
 def get(self):
     """
     Get a listing of subscriptions (paginated if need be)
     """
     return paginate(request, DEFAULT_SUBSCRIPTIONS_TABLE, 'subscriptions')
Example #16
0
 def get(self):
     """
     Get a listing of Registrations (paginated if need be)
     """
     return paginate(request, DEFAULT_REGISTRATIONS_TABLE, 'registrations')