How to use the octodns.record.geo.GeoCodes.validate function in octodns

To help you get started, we’ve selected a few octodns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github github / octodns / tests / test_octodns_record_geo.py View on Github external
def test_validate(self):
        prefix = 'xyz '

        # All valid
        self.assertEquals([], GeoCodes.validate('NA', prefix))
        self.assertEquals([], GeoCodes.validate('NA-US', prefix))
        self.assertEquals([], GeoCodes.validate('NA-US-OR', prefix))

        # Just plain bad
        self.assertEquals(['xyz invalid geo code "XX-YY-ZZ-AA"'],
                          GeoCodes.validate('XX-YY-ZZ-AA', prefix))
        self.assertEquals(['xyz unknown continent code "X-Y-Z"'],
                          GeoCodes.validate('X-Y-Z', prefix))
        self.assertEquals(['xyz unknown continent code "XXX-Y-Z"'],
                          GeoCodes.validate('XXX-Y-Z', prefix))

        # Bad continent
        self.assertEquals(['xyz unknown continent code "XX"'],
                          GeoCodes.validate('XX', prefix))
        # Bad continent good country
        self.assertEquals(['xyz unknown continent code "XX-US"'],
                          GeoCodes.validate('XX-US', prefix))
        # Bad continent good country and province
        self.assertEquals(['xyz unknown continent code "XX-US-OR"'],
                          GeoCodes.validate('XX-US-OR', prefix))

        # Bad country, good continent
        self.assertEquals(['xyz unknown country code "NA-XX"'],
                          GeoCodes.validate('NA-XX', prefix))
github github / octodns / tests / test_octodns_record_geo.py View on Github external
# Bad continent good country
        self.assertEquals(['xyz unknown continent code "XX-US"'],
                          GeoCodes.validate('XX-US', prefix))
        # Bad continent good country and province
        self.assertEquals(['xyz unknown continent code "XX-US-OR"'],
                          GeoCodes.validate('XX-US-OR', prefix))

        # Bad country, good continent
        self.assertEquals(['xyz unknown country code "NA-XX"'],
                          GeoCodes.validate('NA-XX', prefix))
        # Bad country, good continent and state
        self.assertEquals(['xyz unknown country code "NA-XX-OR"'],
                          GeoCodes.validate('NA-XX-OR', prefix))
        # Good country, good continent, but bad match
        self.assertEquals(['xyz unknown country code "NA-GB"'],
                          GeoCodes.validate('NA-GB', prefix))

        # Bad province code, good continent and country
        self.assertEquals(['xyz unknown province code "NA-US-XX"'],
                          GeoCodes.validate('NA-US-XX', prefix))
github github / octodns / tests / test_octodns_record_geo.py View on Github external
self.assertEquals(['xyz unknown continent code "XX-US-OR"'],
                          GeoCodes.validate('XX-US-OR', prefix))

        # Bad country, good continent
        self.assertEquals(['xyz unknown country code "NA-XX"'],
                          GeoCodes.validate('NA-XX', prefix))
        # Bad country, good continent and state
        self.assertEquals(['xyz unknown country code "NA-XX-OR"'],
                          GeoCodes.validate('NA-XX-OR', prefix))
        # Good country, good continent, but bad match
        self.assertEquals(['xyz unknown country code "NA-GB"'],
                          GeoCodes.validate('NA-GB', prefix))

        # Bad province code, good continent and country
        self.assertEquals(['xyz unknown province code "NA-US-XX"'],
                          GeoCodes.validate('NA-US-XX', prefix))
github github / octodns / tests / test_octodns_record_geo.py View on Github external
self.assertEquals([], GeoCodes.validate('NA-US-OR', prefix))

        # Just plain bad
        self.assertEquals(['xyz invalid geo code "XX-YY-ZZ-AA"'],
                          GeoCodes.validate('XX-YY-ZZ-AA', prefix))
        self.assertEquals(['xyz unknown continent code "X-Y-Z"'],
                          GeoCodes.validate('X-Y-Z', prefix))
        self.assertEquals(['xyz unknown continent code "XXX-Y-Z"'],
                          GeoCodes.validate('XXX-Y-Z', prefix))

        # Bad continent
        self.assertEquals(['xyz unknown continent code "XX"'],
                          GeoCodes.validate('XX', prefix))
        # Bad continent good country
        self.assertEquals(['xyz unknown continent code "XX-US"'],
                          GeoCodes.validate('XX-US', prefix))
        # Bad continent good country and province
        self.assertEquals(['xyz unknown continent code "XX-US-OR"'],
                          GeoCodes.validate('XX-US-OR', prefix))

        # Bad country, good continent
        self.assertEquals(['xyz unknown country code "NA-XX"'],
                          GeoCodes.validate('NA-XX', prefix))
        # Bad country, good continent and state
        self.assertEquals(['xyz unknown country code "NA-XX-OR"'],
                          GeoCodes.validate('NA-XX-OR', prefix))
        # Good country, good continent, but bad match
        self.assertEquals(['xyz unknown country code "NA-GB"'],
                          GeoCodes.validate('NA-GB', prefix))

        # Bad province code, good continent and country
        self.assertEquals(['xyz unknown province code "NA-US-XX"'],
github github / octodns / tests / test_octodns_record_geo.py View on Github external
self.assertEquals(['xyz invalid geo code "XX-YY-ZZ-AA"'],
                          GeoCodes.validate('XX-YY-ZZ-AA', prefix))
        self.assertEquals(['xyz unknown continent code "X-Y-Z"'],
                          GeoCodes.validate('X-Y-Z', prefix))
        self.assertEquals(['xyz unknown continent code "XXX-Y-Z"'],
                          GeoCodes.validate('XXX-Y-Z', prefix))

        # Bad continent
        self.assertEquals(['xyz unknown continent code "XX"'],
                          GeoCodes.validate('XX', prefix))
        # Bad continent good country
        self.assertEquals(['xyz unknown continent code "XX-US"'],
                          GeoCodes.validate('XX-US', prefix))
        # Bad continent good country and province
        self.assertEquals(['xyz unknown continent code "XX-US-OR"'],
                          GeoCodes.validate('XX-US-OR', prefix))

        # Bad country, good continent
        self.assertEquals(['xyz unknown country code "NA-XX"'],
                          GeoCodes.validate('NA-XX', prefix))
        # Bad country, good continent and state
        self.assertEquals(['xyz unknown country code "NA-XX-OR"'],
                          GeoCodes.validate('NA-XX-OR', prefix))
        # Good country, good continent, but bad match
        self.assertEquals(['xyz unknown country code "NA-GB"'],
                          GeoCodes.validate('NA-GB', prefix))

        # Bad province code, good continent and country
        self.assertEquals(['xyz unknown province code "NA-US-XX"'],
                          GeoCodes.validate('NA-US-XX', prefix))
github github / octodns / tests / test_octodns_record_geo.py View on Github external
self.assertEquals(['xyz unknown continent code "XXX-Y-Z"'],
                          GeoCodes.validate('XXX-Y-Z', prefix))

        # Bad continent
        self.assertEquals(['xyz unknown continent code "XX"'],
                          GeoCodes.validate('XX', prefix))
        # Bad continent good country
        self.assertEquals(['xyz unknown continent code "XX-US"'],
                          GeoCodes.validate('XX-US', prefix))
        # Bad continent good country and province
        self.assertEquals(['xyz unknown continent code "XX-US-OR"'],
                          GeoCodes.validate('XX-US-OR', prefix))

        # Bad country, good continent
        self.assertEquals(['xyz unknown country code "NA-XX"'],
                          GeoCodes.validate('NA-XX', prefix))
        # Bad country, good continent and state
        self.assertEquals(['xyz unknown country code "NA-XX-OR"'],
                          GeoCodes.validate('NA-XX-OR', prefix))
        # Good country, good continent, but bad match
        self.assertEquals(['xyz unknown country code "NA-GB"'],
                          GeoCodes.validate('NA-GB', prefix))

        # Bad province code, good continent and country
        self.assertEquals(['xyz unknown province code "NA-US-XX"'],
                          GeoCodes.validate('NA-US-XX', prefix))
github github / octodns / tests / test_octodns_record_geo.py View on Github external
def test_validate(self):
        prefix = 'xyz '

        # All valid
        self.assertEquals([], GeoCodes.validate('NA', prefix))
        self.assertEquals([], GeoCodes.validate('NA-US', prefix))
        self.assertEquals([], GeoCodes.validate('NA-US-OR', prefix))

        # Just plain bad
        self.assertEquals(['xyz invalid geo code "XX-YY-ZZ-AA"'],
                          GeoCodes.validate('XX-YY-ZZ-AA', prefix))
        self.assertEquals(['xyz unknown continent code "X-Y-Z"'],
                          GeoCodes.validate('X-Y-Z', prefix))
        self.assertEquals(['xyz unknown continent code "XXX-Y-Z"'],
                          GeoCodes.validate('XXX-Y-Z', prefix))

        # Bad continent
        self.assertEquals(['xyz unknown continent code "XX"'],
                          GeoCodes.validate('XX', prefix))
        # Bad continent good country
        self.assertEquals(['xyz unknown continent code "XX-US"'],
                          GeoCodes.validate('XX-US', prefix))
github github / octodns / tests / test_octodns_record_geo.py View on Github external
# All valid
        self.assertEquals([], GeoCodes.validate('NA', prefix))
        self.assertEquals([], GeoCodes.validate('NA-US', prefix))
        self.assertEquals([], GeoCodes.validate('NA-US-OR', prefix))

        # Just plain bad
        self.assertEquals(['xyz invalid geo code "XX-YY-ZZ-AA"'],
                          GeoCodes.validate('XX-YY-ZZ-AA', prefix))
        self.assertEquals(['xyz unknown continent code "X-Y-Z"'],
                          GeoCodes.validate('X-Y-Z', prefix))
        self.assertEquals(['xyz unknown continent code "XXX-Y-Z"'],
                          GeoCodes.validate('XXX-Y-Z', prefix))

        # Bad continent
        self.assertEquals(['xyz unknown continent code "XX"'],
                          GeoCodes.validate('XX', prefix))
        # Bad continent good country
        self.assertEquals(['xyz unknown continent code "XX-US"'],
                          GeoCodes.validate('XX-US', prefix))
        # Bad continent good country and province
        self.assertEquals(['xyz unknown continent code "XX-US-OR"'],
                          GeoCodes.validate('XX-US-OR', prefix))

        # Bad country, good continent
        self.assertEquals(['xyz unknown country code "NA-XX"'],
                          GeoCodes.validate('NA-XX', prefix))
        # Bad country, good continent and state
        self.assertEquals(['xyz unknown country code "NA-XX-OR"'],
                          GeoCodes.validate('NA-XX-OR', prefix))
        # Good country, good continent, but bad match
        self.assertEquals(['xyz unknown country code "NA-GB"'],
                          GeoCodes.validate('NA-GB', prefix))
github github / octodns / octodns / record / __init__.py View on Github external
try:
                    geos = rule['geos']
                except KeyError:
                    geos = []
                    if seen_default:
                        reasons.append('rule {} duplicate default'
                                       .format(rule_num))
                    seen_default = True

                if not isinstance(geos, (list, tuple)):
                    reasons.append('rule {} geos must be a list'
                                   .format(rule_num))
                else:
                    for geo in geos:
                        reasons.extend(GeoCodes.validate(geo, 'rule {} '
                                                         .format(rule_num)))

        return reasons
github github / octodns / octodns / record / __init__.py View on Github external
try:
                    geos = rule['geos']
                except KeyError:
                    geos = []
                    if seen_default:
                        reasons.append('rule {} duplicate default'
                                       .format(rule_num))
                    seen_default = True

                if not isinstance(geos, (list, tuple)):
                    reasons.append('rule {} geos must be a list'
                                   .format(rule_num))
                else:
                    for geo in geos:
                        reasons.extend(GeoCodes.validate(geo, 'rule {} '
                                                         .format(rule_num)))

        return reasons