示例#1
0
    def test_check_err_create_bad_dom(self):
        """
        Tests that CheckEngine produces expected CheckStatus, when checking domain error exists
        with the CustomizedAlgo creation Rest service.
        """

        # Re-activate checking rules
        CheckEngine.set_checking_rules(
            FactoryCatalogue.TYPE_CHECKING_FUNCTIONS)

        my_custom_outside_domain = self.init_rsrc_outside_domain()

        http_req = self.request_factory.post(
            path=reverse('pattern_custom_algos_dummy'),
            data=CustomizedAlgoWs(my_custom_outside_domain).to_json(),
            content_type="application/json_util")

        http_response = create_custom_algo(http_req)

        # Display the check result
        result = json_io.decode_json_from_http_response(http_response)

        self.info("response loaded={}".format(result))
        self.info("response status={}".format(http_response.status_code))

        self.assertTrue(http_response.status_code ==
                        HttpResponseFactory.BAD_REQUEST_HTTP_STATUS)
示例#2
0
    def test_custo_create_200(self):
        """
        Tests the nominal Creation of CustomizedAlgo: we prepare the data and then submit creation
        """

        # Preparing the data ...
        my_new_custom_algo = self.init_resource_named(
            name="custom algo for create seq3", save_in_db=False)

        data = CustomizedAlgoWs(my_new_custom_algo).to_json()

        # ... testing the service
        http_req = self.request_factory.post(
            path=reverse('pattern_custom_algos_dummy'),
            data=data,
            content_type="application/json_util")

        http_response = create_custom_algo(http_req)

        result = json_io.decode_json_from_http_response(http_response)

        self.info("!!! response loaded={} !!!".format(result))
        self.info("!!! response status={} !!!".format(
            http_response.status_code))

        self.assertTrue(http_response.status_code ==
                        HttpResponseFactory.CREATED_HTTP_STATUS)
示例#3
0
    def test_custo_create_400(self):
        """
        Tests the Creation failure case: BAD_REQUEST_HTTP_STATUS
        """

        http_req = self.request_factory.post(
            path=reverse('pattern_custom_algos_dummy'),
            data="bad content",
            content_type="application/json_util")

        http_response_2 = create_custom_algo(http_req)

        self.assertTrue(http_response_2.status_code ==
                        HttpResponseFactory.BAD_REQUEST_HTTP_STATUS)
示例#4
0
    def test_custo_create_409(self):
        """
        Tests the Creation failure case: CONFLICT_HTTP_STATUS
        """

        http_req = self.request_factory.post(
            path=reverse('pattern_custom_algos_dummy'),
            data=CustomizedAlgoWs(self.my_custom_algo_in_DB).to_json(),
            content_type="application/json_util")

        http_response = create_custom_algo(http_req)

        self.assertTrue(http_response.status_code ==
                        HttpResponseFactory.CONFLICT_HTTP_STATUS)