Example #1
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")
Example #2
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")