示例#1
0
    def request(self, data, token=None):
        authorization_header = ({
            "HTTP_AUTHORIZATION":
            "Token {}".format(token.key)
        } if token else {})

        request = self.factory.post("/v1/organization/org/", data,
                                    **authorization_header)

        response = OrganizationViewSet.as_view({"post": "create"})(request)
        response.render()
        content_data = json.loads(response.content)
        return (response, content_data)
示例#2
0
 def request(self, param, value, token=None):
     authorization_header = ({
         "HTTP_AUTHORIZATION":
         "Token {}".format(token.key)
     } if token else {})
     request = self.factory.get(
         "/v1/organization/org/?{}={}".format(param, value),
         **authorization_header)
     response = OrganizationViewSet.as_view({"get": "list"})(
         request, organization=self.organization.uuid)
     response.render()
     content_data = json.loads(response.content)
     return (response, content_data)
示例#3
0
 def request_get_org(self, organization_uuid, token=None):
     authorization_header = ({
         "HTTP_AUTHORIZATION":
         "Token {}".format(token.key)
     } if token else {})
     request = self.factory.get(
         f"v1/organization/project/?organization={organization_uuid}",
         **authorization_header,
     )
     response = OrganizationViewSet.as_view({"get": "list"})(request)
     response.render()
     content_data = json.loads(response.content)
     return (response, content_data)
示例#4
0
    def request2(self, param, method, token=None):
        authorization_header = ({
            "HTTP_AUTHORIZATION":
            "Token {}".format(token.key)
        } if token else {})
        if method == "GET":
            request = self.factory.get(
                f"/v1/organization/org/billing/{param}/",
                **authorization_header)

            response = OrganizationViewSet.as_view(
                {"get": "active_contacts_limit"})(request)
        else:
            request = self.factory.patch(
                f"/v1/organization/org/billing/{param}/",
                **authorization_header,
            )

            response = OrganizationViewSet.as_view(
                {"patch": "active_contacts_limit"})(request)

        content_data = json.loads(response.content)
        return (response, content_data)
示例#5
0
    def request(self, param, value, token=None):
        authorization_header = ({
            "HTTP_AUTHORIZATION":
            "Token {}".format(token.key)
        } if token else {})

        request = self.factory.get(
            f"/v1/organization/org/billing/{param}/{value}/",
            **authorization_header)
        response = OrganizationViewSet.as_view(
            {"get": "organization_on_limit"})(request, organization_uuid=value)

        content_data = json.loads(response.content)
        return (response, content_data)
示例#6
0
    def request(self, token=None):
        authorization_header = ({
            "HTTP_AUTHORIZATION":
            "Token {}".format(token.key)
        } if token else {})

        request = self.factory.get(
            "/v1/organization/org/billing/precification",
            **authorization_header)

        response = OrganizationViewSet.as_view(
            {"get": "get_billing_precification"})(request)

        content_data = json.loads(response.content)
        return (response, content_data)
示例#7
0
    def request_enforce_2fa(self, organization_uuid, data, token=None):
        authorization_header = ({
            "HTTP_AUTHORIZATION":
            "Token {}".format(token.key)
        } if token else {})
        request = self.factory.patch(
            f"/v1/organization/org/enforce-two-factor-auth/{organization_uuid}/",
            data=json.dumps(data),
            content_type="application/json",
            format="json",
            **authorization_header,
        )
        response = OrganizationViewSet.as_view({"patch": "set_2fa_required"})(
            request,
            organization_uuid=self.organization.uuid,
        )

        content_data = json.loads(response.content)
        return response, content_data
示例#8
0
    def request(self, value, data={}, token=None):
        authorization_header = ({
            "HTTP_AUTHORIZATION":
            "Token {}".format(token.key)
        } if token else {})
        request = self.factory.post(
            f"/v1/organization/org/billing/add-additional-information/{value}/",
            **authorization_header,
            data=data,
        )
        response = OrganizationViewSet.as_view({
            "post":
            "add_additional_billing_information"
        })(request, organization_uuid=self.organization.uuid)

        if type(response) == JsonResponse:
            content_data = json.loads(response.content)
            return response, content_data

        response.render()
        content_data = json.loads(response.content)
        return response, content_data
示例#9
0
    def request(self, param, value, method, token=None):
        authorization_header = ({
            "HTTP_AUTHORIZATION":
            "Token {}".format(token.key)
        } if token else {})

        request = self.factory.patch(
            f"/v1/organization/org/billing/{param}/{value}/",
            **authorization_header,
        )

        response = OrganizationViewSet.as_view({"patch": f"{method}"})(
            request,
            organization_uuid=self.organization.uuid,
        )
        if type(response) == JsonResponse:
            content_data = json.loads(response.content)
            return response, content_data

        response.render()
        content_data = json.loads(response.content)
        return response, content_data
示例#10
0
    def request_change_plan(self, value, data={}, token=None):
        authorization_header = ({
            "HTTP_AUTHORIZATION":
            "Token {}".format(token.key)
        } if token else {})
        request = self.factory.patch(
            f"/v1/organization/org/billing/change-plan/{value}/",
            data=json.dumps(data),
            content_type="application/json",
            format="json",
            **authorization_header,
        )
        response = OrganizationViewSet.as_view({"patch": "change_plan"})(
            request,
            organization_uuid=self.organization.uuid,
        )

        if type(response) == JsonResponse:
            content_data = json.loads(response.content)
            return response, content_data

        response.render()
        content_data = json.loads(response.content)
        return response, content_data