Beispiel #1
0
    def test_resource_list(self):
        request = self.factory.get('/resource/')
        request.user = self.user

        v = setup_view(ResourceDownloadView(), request)
        self.assertEqual(v.template_name, "resource/index.html")

        context = v.get_context_data()
        self.assertTrue(len(context['resources']))
Beispiel #2
0
    def _do_request(self, app_code):
        request = self.factory.get(
            "/app/check/app_code/?app_code={}".format(app_code))
        request.user = self.user
        # test view template or context_data
        v = setup_view(CheckAppCodeView(), request)
        context = v.get_context_data()
        result = context["result"]

        return result
Beispiel #3
0
    def test_get(self):
        # not include resolves the url
        # https://stackoverflow.com/questions/48580465/django-requestfactory-loses-url-kwargs
        request = self.factory.get('/saas/test/release/record/')
        kwargs = {'app_code': 'test'}
        request.user = self.user

        v = setup_view(RecordView(), request, **kwargs)
        context = v.get_context_data()

        self.assertEqual(self.code, context["app_code"])
        self.assertEqual(AppStateEnum.DEVELOPMENT.value, context["app_state"])
Beispiel #4
0
    def test_get(self):
        app_code = 'test'
        error_id = '1'
        url = "/app/{}/error/{}/".format(app_code, error_id)
        template_name = 'error/app_error_dialog{}.html'.format(error_id)

        request = self.factory.get(url)
        request.user = self.user
        kwargs = {"app_code": app_code, "error_id": error_id}

        # test view template or context_data
        v = setup_view(ErrorView(), request, **kwargs)

        self.assertEqual(v.get_template_names(), [template_name])

        context = v.get_context_data()
        self.assertEqual(context["app_code"], app_code)
Beispiel #5
0
    def test_get(self):
        request = self.factory.get('/guide/newbie/')
        request.user = self.user

        # test requests
        view = ServiceIntroductionView.as_view()
        response = view(request)
        self.assertEqual(response.status_code, 200)

        # test view template or context_data
        v = setup_view(NewbieView(), request)
        self.assertEqual(v.template_name, "guide/newbie.html")

        context = v.get_context_data()
        paas_host = "{}://{}".format(settings.HTTP_SCHEMA,
                                     settings.PAAS_DOMAIN)

        self.assertEqual(context["paas_host"], paas_host)