Beispiel #1
0
    def check_access(self):
        '''
        Check whether the permission was given to access stream resources or not.
        '''
        url = self.endpoint.format(self.config['subdomain'])
        HEADERS['Authorization'] = 'Bearer {}'.format(
            self.config["access_token"])

        http.call_api(url,
                      self.request_timeout,
                      params={'per_page': 1},
                      headers=HEADERS)
Beispiel #2
0
 def check_access(self):
     '''
     Check whether the permission was given to access stream resources or not.
     '''
     url = self.endpoint.format(self.config['subdomain'], '1')
     HEADERS['Authorization'] = 'Bearer {}'.format(
         self.config["access_token"])
     try:
         http.call_api(url,
                       self.request_timeout,
                       params={'per_page': 1},
                       headers=HEADERS)
     except http.ZendeskNotFoundError:
         #Skip 404 ZendeskNotFoundError error as goal is to just check to whether TicketComments have read permission or not
         pass
Beispiel #3
0
    def check_access(self):
        '''
        Check whether the permission was given to access stream resources or not.
        '''
        url = self.endpoint.format(self.config['subdomain'])
        # Convert start_date parameter to timestamp to pass with request param
        start_time = datetime.datetime.strptime(self.config['start_date'],
                                                START_DATE_FORMAT).timestamp()
        HEADERS['Authorization'] = 'Bearer {}'.format(
            self.config["access_token"])

        http.call_api(url,
                      self.request_timeout,
                      params={
                          'start_time': start_time,
                          'per_page': 1
                      },
                      headers=HEADERS)
Beispiel #4
0
    def test_call_api_handles_timeout_error(self, mock_get, mock_sleep):
        """We mock request method to raise a `Timeout` and expect the tap to retry this up to 5 times,
        """
        mock_get.side_effect = requests.exceptions.Timeout

        try:
            responses = http.call_api(url='some_url',
                                      request_timeout=300,
                                      params={},
                                      headers={})
        except requests.exceptions.Timeout as e:
            pass

        # Verify the request retry 5 times on timeout
        self.assertEqual(mock_get.call_count, 5)