コード例 #1
0
    def test_get_matching_request_count(self):
        resp = RequestCountResponse(count=4).get_json_data()
        responses.add(responses.POST, 'http://localhost/__admin/requests/count', json=resp, status=200)

        request = NearMissMatchPatternRequest(url='test', method='GET')

        r = Requests.get_matching_request_count(request)
        self.assertIsInstance(r, RequestCountResponse)
        self.assertEquals(4, r.count)
コード例 #2
0
    def test_get_matching_requests(self):
        e = RequestResponseFindResponse(
            requests=[RequestResponseRequest(method='GET', url='test'), ],
        )
        resp = e.get_json_data()
        responses.add(responses.POST, 'http://localhost/__admin/requests/find', json=resp, status=200)

        request = NearMissMatchPatternRequest(url='test', method='GET')

        r = Requests.get_matching_requests(request)
        self.assertIsInstance(r, RequestResponseFindResponse)
        self.assertIsInstance(r.requests, list)
        self.assertEquals(1, len(r.requests))
        result = r.requests[0]
        self.assertIsInstance(result, RequestResponseRequest)
        self.assertEquals('GET', result.method)
        self.assertEquals('test', result.url)
コード例 #3
0
    def test_find_nearest_misses_by_request_pattern(self):
        e = NearMissMatchResponse(
            near_misses=[NearMissMatch(
                request=NearMissMatchRequest(url='test', method='GET'),
                request_pattern=NearMissRequestPatternResult(url='test1', method='GET'),
                match_result=NearMissMatchResult(distance=0.5)
            ), ]
        )
        resp = e.get_json_data()
        responses.add(responses.POST, 'http://localhost/__admin/near-misses/request-pattern', json=resp, status=200)

        near_miss_match_request_pattern = NearMissMatchPatternRequest(url='test', method=HttpMethods.GET)
        r = NearMisses.find_nearest_misses_by_request_pattern(near_miss_match_request_pattern)
        self.assertIsInstance(r, NearMissMatchResponse)
        self.assertIsInstance(r.near_misses, list)
        result = r.near_misses[0]
        self.assertIsInstance(result, NearMissMatch)
        self.assertEquals('test', result.request.url)