Esempio n. 1
0
    def test_iox_phy_intf_validator_error(self):
        frost = Frosting("--{{var}}--")
        structure = {
            "var": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.VLAN'
            }
        }

        frost.load_structure(structure)
        with self.assertRaises(frosting.exceptions.FieldInputNotValid):
            frost.add('var', 'xe-0/1/2/1')
Esempio n. 2
0
    def test_cidrv6_validator_error(self):
        frost = Frosting("--{{var}}--")
        structure = {
            "var": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.CIDRv6'
            }
        }

        frost.load_structure(structure)
        with self.assertRaises(frosting.exceptions.FieldInputNotValid):
            frost.add('var', '2001:db8:f00:ba44::1ac')
Esempio n. 3
0
    def test_asn_validator_error(self):
        frost = Frosting("--{{asn}}--")
        structure = {
            "asn": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.ASN'
            }
        }

        frost.load_structure(structure)
        with self.assertRaises(frosting.exceptions.FieldInputNotValid):
            frost.add('asn', 'WRONG')
Esempio n. 4
0
 def test_regex_validator_error(self):
     frost = Frosting("--{{foo}}--")
     structure = {
         "foo": {
             'type': 'frosting.types.TextInput',
             'validator': 'frosting.validators.RegexValidator',
             'regex': '^[a-z][0-9]$'
         }
     }
     frost.load_structure(structure)
     with self.assertRaises(frosting.exceptions.FieldInputNotValid):
         frost.add('foo', 'INCORRECT')
Esempio n. 5
0
    def test_regex_validator(self):
        frost = Frosting("--{{foo}}--")
        structure = {
            "foo": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.RegexValidator',
                'regex': '^[a-z][0-9]$'
            }
        }
        frost.load_structure(structure)
        frost.add('foo', 'b7')
        result = frost.compile()

        self.assertEqual(result, "--b7--")
Esempio n. 6
0
    def test_cidrv6_validator(self):
        frost = Frosting("--{{var}}--")
        structure = {
            "var": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.CIDRv6'
            }
        }

        frost.load_structure(structure)
        frost.add('var', '2001:db8:f00:ba44::1ac/96')
        result = frost.compile()

        self.assertEqual(result, "--2001:db8:f00:ba44::1ac/96--")
Esempio n. 7
0
    def test_cidrv4_validator(self):
        frost = Frosting("--{{var}}--")
        structure = {
            "var": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.CIDRv4'
            }
        }

        frost.load_structure(structure)
        frost.add('var', '198.18.0.10/32')
        result = frost.compile()

        self.assertEqual(result, "--198.18.0.10/32--")
Esempio n. 8
0
    def test_iox_phy_intf_validator(self):
        frost = Frosting("--{{var}}--")
        structure = {
            "var": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.IOSXR_Physical_Interface'
            }
        }

        frost.load_structure(structure)
        frost.add('var', 'TenGigE0/1/2/3')
        result = frost.compile()

        self.assertEqual(result, "--TenGigE0/1/2/3--")
Esempio n. 9
0
    def test_vlan_validator(self):
        frost = Frosting("--{{var}}--")
        structure = {
            "var": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.VLAN'
            }
        }

        frost.load_structure(structure)
        frost.add('var', '100')
        result = frost.compile()

        self.assertEqual(result, "--100--")
Esempio n. 10
0
    def test_asn_validator(self):
        frost = Frosting("--{{asn}}--")
        structure = {
            "asn": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.ASN'
            }
        }

        frost.load_structure(structure)
        frost.add('asn', '65123')
        result = frost.compile()

        self.assertEqual(result, "--65123--")
Esempio n. 11
0
    def test_limit_string_input(self):
        frost = Frosting(self.template)
        structure = {
            "var1": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.IPv4_Address'
            },
            "var2": {
                'type': 'frosting.types.IntegerInput',
                'limit': '1..100'
            }
        }
        frost.load_structure(structure)
        frost.add("var1", "1.1.1.1")
        frost.add("var2", "99")
        result = frost.compile()

        self.assertEqual(result, "1.1.1.1:99")
Esempio n. 12
0
    def test_dict_structure(self):
        frost = Frosting(self.template)
        structure = {
            "var1": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.IPv4_Address'
            },
            "var2": {
                'type': 'frosting.types.TextInput',
                'validator': 'frosting.validators.IPv4_Address'
            }
        }
        frost.load_structure(structure)
        frost.add("var1", "1.1.1.1")
        frost.add("var2", "2.2.2.2")
        result = frost.compile()

        self.assertEqual(result, "1.1.1.1:2.2.2.2")