Ejemplo n.º 1
0
    def test_get_status_code_title(self):
        title = get_status_code_title(500)
        expect(title).to_equal('Internal Server Error')

        title = get_status_code_title(599)
        expect(title).to_equal('Tornado Timeout')

        title = get_status_code_title(120)
        expect(title).to_equal('Unknown')
Ejemplo n.º 2
0
    def get(self):
        from_date = datetime.datetime.utcnow() - datetime.timedelta(days=1)
        requests = Request.get_requests_count_by_status_in_period_of_days(self.db, from_date=from_date)

        result = []
        for request in requests:
            result.append({
                'statusCode': request.status_code,
                'statusCodeTitle': get_status_code_title(request.status_code),  # FIXME: is it code or title??
                'count': request.count,
            })

        self.write_json(result)
Ejemplo n.º 3
0
    def get_all_status_code(self, db):
        status_code_list = db \
            .query(distinct(Request.status_code).label('status_code')) \
            .all()

        result = []

        for value in status_code_list:
            result.append({
                'statusCode': value.status_code,
                'statusCodeTitle': get_status_code_title(value.status_code)
          })

        return result
Ejemplo n.º 4
0
    def get_all_status_code(self, db):
        status_code_list = db \
            .query(distinct(Request.status_code).label('status_code')) \
            .all()

        result = []

        for value in status_code_list:
            result.append({
                'statusCode': value.status_code,
                'statusCodeTitle': get_status_code_title(value.status_code)
          })

        return result
Ejemplo n.º 5
0
    def get(self, domain_name, status_code):

        if not domain_name:
            self.set_status(404, 'Domain %s not found' % domain_name)
            return

        if not status_code:
            self.set_status(404, 'Status code %s not found' % status_code)
            return

        if status_code == '200':
            self.set_status(403, 'Status code %s is not allowed' % status_code)
            return

        current_page = int(self.get_argument('current_page', 1))
        page_size = int(self.get_argument('page_size', 10))

        requests = Request.get_requests_by_status_code(
            domain_name,
            status_code,
            self.db,
            current_page=current_page,
            page_size=page_size
        )

        requests_count = Request.get_requests_by_status_count(
            domain_name,
            status_code,
            self.db
        )

        result = {
            'statusCodeTitle': get_status_code_title(status_code),
            'requestsCount': requests_count,
            'requests': []
        }

        for request in requests:
            result['requests'].append({
                'id': request.id,
                'url': request.url,
                'review_url': request.review_url,
                'completed_date': request.completed_date
            })

        self.write_json(result)
Ejemplo n.º 6
0
    def get(self):
        requests = self.girl.get('failed_responses_count') or []
        domain_filter = self.get_argument('domain_filter', None)

        if not domain_filter:
            domain_filter = '_all'

        result = []
        if domain_filter in requests:
            for status_code, count in requests[domain_filter]:
                result.append({
                    'statusCode': status_code,
                    'statusCodeTitle': get_status_code_title(status_code),
                    'count': count,
                })

        self.write_json(result)
Ejemplo n.º 7
0
    def get(self, domain_name, status_code):

        if not domain_name:
            self.set_status(404, self._('Domain %s not found') % domain_name)
            return

        if not status_code:
            self.set_status(404,
                            self._('Status code %s not found') % status_code)
            return

        if status_code == '200':
            self.set_status(
                403,
                self._('Status code %s is not allowed') % status_code)
            return

        current_page = int(self.get_argument('current_page', 1))
        page_size = int(self.get_argument('page_size', 10))

        requests = Request.get_requests_by_status_code(
            domain_name,
            status_code,
            self.db,
            current_page=current_page,
            page_size=page_size)

        requests_count = Request.get_requests_by_status_count(
            domain_name, status_code, self.db)

        result = {
            'statusCodeTitle': get_status_code_title(status_code),
            'requestsCount': requests_count,
            'requests': []
        }

        for request in requests:
            result['requests'].append({
                'id': request.id,
                'url': request.url,
                'review_url': request.review_url,
                'completed_date': request.completed_date
            })

        self.write_json(result)
Ejemplo n.º 8
0
    def get_status_code_info(self, domain_name, db):
        result = []

        query = db \
            .query(
                Request.status_code,
                sa.func.count(Request.status_code).label('total')
            ) \
            .filter(Request.domain_name == domain_name) \
            .group_by(Request.status_code) \
            .all()

        for i in query:
            result.append({
                'code': i.status_code,
                'title': get_status_code_title(i.status_code),
                'total': i.total
            })

        return result
Ejemplo n.º 9
0
    def get_status_code_info(self, domain_name, db):
        result = []

        query = db \
            .query(
                Request.status_code,
                sa.func.count(Request.status_code).label('total')
            ) \
            .filter(Request.domain_name == domain_name) \
            .group_by(Request.status_code) \
            .all()

        for i in query:
            result.append({
                'code': i.status_code,
                'title': get_status_code_title(i.status_code),
                'total': i.total
            })

        return result
Ejemplo n.º 10
0
    def get(self):
        requests = self.girl.get('failed_responses_count') or []
        domain_filter = self.get_argument('domain_filter', None)

        if not domain_filter:
            domain_filter = '_all'

        result = []
        if domain_filter in requests:
            for status_code, count in requests[domain_filter]:
                result.append({
                    'statusCode':
                    status_code,
                    'statusCodeTitle':
                    get_status_code_title(status_code),
                    'count':
                    count,
                })

        self.write_json(result)