コード例 #1
0
    def hit_the_api(self):
        path = reverse("audio-list", kwargs={"version": "v3"})
        request = RequestFactory().get(path)

        # Create the view and change the milestones to be something we can test
        # (Otherwise, we need to make 1,000 requests in this test)
        view = AudioViewSet.as_view({"get": "list"})
        view.milestones = [1]

        # Set the attributes needed in the absence of middleware
        request.user = self.user
        request.resolver_match = ResolverMatch(view, {"version": "v3"},
                                               "audio-list")

        view(request)
コード例 #2
0
ファイル: tests.py プロジェクト: freelawproject/courtlistener
    def hit_the_api(self):
        path = reverse('audio-list', kwargs={'version': 'v3'})
        request = RequestFactory().get(path)

        # Create the view and change the milestones to be something we can test
        # (Otherwise, we need to make 1,000 requests in this test)
        view = AudioViewSet.as_view({'get': 'list'})
        view.milestones = [1]

        # Set the attributes needed in the absence of middleware
        request.user = self.user
        request.resolver_match = ResolverMatch(
            view,
            {'version': 'v3'},
            'audio-list',
        )

        view(request)