Exemplo n.º 1
0
    def test_constant_values(self):

        config = AutoRestValidationTestConfiguration(
            "abc123", "12-34-5678", base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestValidationTest(config)

        client.get_with_constant_in_path()

        # TODO: Const body should be built implicitly
        body = Product(child=ChildProduct())
        body.const_child = ConstantProduct()

        product = client.post_with_constant_in_body(body=body)
        self.assertIsNotNone(product)
Exemplo n.º 2
0
    def test_constant_values(self):

        config = AutoRestValidationTestConfiguration(
            "abc123",
            "12-34-5678",
            base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestValidationTest(config)

        client.get_with_constant_in_path()

        # TODO: Const body should be built implicitly
        body = Product(child=ChildProduct())
        body.const_child = ConstantProduct()

        product = client.post_with_constant_in_body(body=body)
        self.assertIsNotNone(product)
Exemplo n.º 3
0
    def test_constant_values(self):
        client = AutoRestValidationTest("abc123",
                                        "12-34-5678",
                                        base_url="http://localhost:3000")

        client.get_with_constant_in_path()

        body = Product(child=ChildProduct())
        product = client.post_with_constant_in_body(body=body)
        self.assertIsNotNone(product)
Exemplo n.º 4
0
    def test_validation(self):
        client = AutoRestValidationTest(
            "abc123",
            "12-34-5678",
            base_url="http://*****:*****@#$", 100)
        except ValidationError as err:
            self.assertEqual(err.rule, "pattern")
            self.assertEqual(err.target, "resource_group_name")

        try:
            client.validation_of_method_parameters("123", 105)
        except ValidationError as err:
            self.assertEqual(err.rule, "multiple")
            self.assertEqual(err.target, "id")

        try:
            client.validation_of_method_parameters("123", 0)
        except ValidationError as err:
            self.assertEqual(err.rule, "minimum")
            self.assertEqual(err.target, "id")

        try:
            client.validation_of_method_parameters("123", 2000)
        except ValidationError as err:
            self.assertEqual(err.rule, "maximum")
            self.assertEqual(err.target, "id")

        try:
            tempproduct=Product(child=ChildProduct(), capacity=0)
            client.validation_of_body("123", 150, tempproduct)
        except ValidationError as err:
            self.assertEqual(err.rule, "minimum_ex")
            self.assertEqual(err.target, "capacity")

        try:
            tempproduct=Product(child=ChildProduct(), capacity=100)
            client.validation_of_body("123", 150, tempproduct)
        except ValidationError as err:
            self.assertEqual(err.rule, "maximum_ex")
            self.assertEqual(err.target, "capacity")

        try:
            tempproduct=Product(child=ChildProduct(),
                display_names=["item1","item2","item3","item4","item5","item6","item7"])
            client.validation_of_body("123", 150, tempproduct)
        except ValidationError as err:
            self.assertEqual(err.rule, "max_items")
            self.assertEqual(err.target, "display_names")

        client2 = AutoRestValidationTest(
            "abc123",
            "abc",
            base_url="http://localhost:3000")

        try:
            client2.validation_of_method_parameters("123", 150)
        except ValidationError as err:
            self.assertEqual(err.rule, "pattern")
            self.assertEqual(err.target, "self.config.api_version")
Exemplo n.º 5
0
    def test_validation(self):

        config = AutoRestValidationTestConfiguration(
            "abc123",
            "12-34-5678",
            base_url="http://*****:*****@#$", 100)
        except ValidationError as err:
            self.assertEqual(err.rule, "pattern")
            self.assertEqual(err.target, "resource_group_name")

        try:
            client.validation_of_method_parameters("123", 105)
        except ValidationError as err:
            self.assertEqual(err.rule, "multiple")
            self.assertEqual(err.target, "id")

        try:
            client.validation_of_method_parameters("123", 0)
        except ValidationError as err:
            self.assertEqual(err.rule, "minimum")
            self.assertEqual(err.target, "id")

        try:
            client.validation_of_method_parameters("123", 2000)
        except ValidationError as err:
            self.assertEqual(err.rule, "maximum")
            self.assertEqual(err.target, "id")

        try:
            tempproduct=Product(child=ChildProduct(), capacity=0)
            tempproduct.const_child=ConstantProduct()
            client.validation_of_body("123", 150, tempproduct)
        except ValidationError as err:
            self.assertEqual(err.rule, "minimum_ex")
            self.assertEqual(err.target, "capacity")

        try:
            tempproduct=Product(child=ChildProduct(), capacity=100)
            tempproduct.const_child=ConstantProduct()
            client.validation_of_body("123", 150, tempproduct)
        except ValidationError as err:
            self.assertEqual(err.rule, "maximum_ex")
            self.assertEqual(err.target, "capacity")

        try:
            tempproduct=Product(child=ChildProduct(),
                display_names=["item1","item2","item3","item4","item5","item6","item7"])
            tempproduct.const_child=ConstantProduct()
            client.validation_of_body("123", 150, tempproduct)
        except ValidationError as err:
            self.assertEqual(err.rule, "max_items")
            self.assertEqual(err.target, "display_names")

        config2 = AutoRestValidationTestConfiguration(
            "abc123",
            "abc",
            base_url="http://localhost:3000")
        config2.log_level = log_level
        client2 = AutoRestValidationTest(config2)

        try:
            client2.validation_of_method_parameters("123", 150)
        except ValidationError as err:
            self.assertEqual(err.rule, "pattern")
            self.assertEqual(err.target, "self.config.api_version")