# Path: iprestrict/admin.py
# NOT_LETTER = re.compile(r'[^A-Z]+')
# class RuleAdmin(admin.ModelAdmin):
# class IPRangeForm(forms.ModelForm):
#     class Meta:
# class IPRangeInline(admin.TabularInline):
# class IPLocationForm(forms.ModelForm):
#     class Meta:
# class IPLocationInline(admin.TabularInline):
# class RangeBasedIPGroupAdmin(admin.ModelAdmin):
# class LocationBasedIPGroupAdmin(admin.ModelAdmin):
#     def clean(self):
#     def clean_country_codes(self):
# 
# Path: iprestrict/models.py
# TYPE_LOCATION = 'location'
# TYPE_RANGE = 'range'
#     TYPE_CHOICES = ((TYPE_LOCATION, 'Location based'),
#                     (TYPE_RANGE, 'Range based'))
#     TYPE = None
#     TYPE = TYPE_RANGE
#     TYPE = TYPE_LOCATION
#     ACTION_CHOICES = (
#         ('A', 'ALLOW'),
#         ('D', 'DENY')
#     )
# class IPGroupManager(models.Manager):
# class IPGroup(models.Model):
#     class Meta:
# class RangeBasedIPGroup(IPGroup):
#     class Meta:
# class LocationBasedIPGroup(IPGroup):
#     class Meta:
# class IPRange(models.Model):
#     class Meta:
# class IPLocation(models.Model):
#     class Meta:
# class Rule(models.Model):
#     class Meta:
# class ReloadRulesRequest(models.Model):
#     def get_queryset(self):
#     def __init__(self, *args, **kwargs):
#     def load(self):
#     def save(self, *args, **kwargs):
#     def __str__(self):
# def typed_ip_group(ip_group):
#     def load_ranges(self):
#     def ranges(self, ip_type=None):
#     def matches(self, ip):
#     def details_str(self):
#     def load_locations(self):
#     def matches(self, ip):
#     def details_str(self):
#     def start(self):
#     def end(self):
#     def ip_type(self):
#     def __contains__(self, ip):
#     def __str__(self):
#     def __contains__(self, country_code):
#     def __str__(self):
#     def __init__(self, *args, **kwargs):
#     def regex(self):
#     def matches_url(self, url):
#     def matches_ip(self, ip):
#     def is_restricted(self):
#     def is_allowed(self):
#     def action_str(self):
#     def swap_with_rule(self, other):
#     def move_up(self):
#     def move_up_url(self):
#     def move_down_url(self):
#     def move_down(self):
#     def save(self, *args, **kwargs):
#     def request_reload(cls):
#     def last_request():
# 
# Path: iprestrict/geoip.py
# NO_COUNTRY = 'XX'


from django.test import TestCase
from iprestrict import admin, models
from iprestrict.geoip import NO_COUNTRY
        self.assertIn("cidr_prefix_length", form.errors)
        self.assertIn("Must be a number between", "\n".join(form.errors["cidr_prefix_length"]))

    def test_cidr_prefix_length_for_ipv6(self):
        form_data = {
            "ip_group": self.all_group.pk,
            "first_ip": "::1",
            "cidr_prefix_length": 127,
        }
        form = admin.IPRangeForm(data=form_data)
        self.assertTrue(form.is_valid())

    def test_ipv6_cidr_prefix_length_invalid(self):
        form_data = {
            "ip_group": self.all_group.pk,
            "first_ip": "::1",
            "cidr_prefix_length": 130,
        }
        form = admin.IPRangeForm(data=form_data)
        self.assertFalse(form.is_valid())
        self.assertIn("cidr_prefix_length", form.errors)
        self.assertIn("Must be a number between", "\n".join(form.errors["cidr_prefix_length"]))


    def test_ip_types(self):
        form_data = {
            "ip_group": self.all_group.pk,
            "first_ip": "192.168.1.1",
            "last_ip": "fe80::9eeb:e8ff:fe0e:8a21",
        }

# Path: iprestrict/admin.py
# NOT_LETTER = re.compile(r'[^A-Z]+')
# class RuleAdmin(admin.ModelAdmin):
# class IPRangeForm(forms.ModelForm):
#     class Meta:
# class IPRangeInline(admin.TabularInline):
# class IPLocationForm(forms.ModelForm):
#     class Meta:
# class IPLocationInline(admin.TabularInline):
# class RangeBasedIPGroupAdmin(admin.ModelAdmin):
# class LocationBasedIPGroupAdmin(admin.ModelAdmin):
#     def clean(self):
#     def clean_country_codes(self):
# 
# Path: iprestrict/models.py
# TYPE_LOCATION = 'location'
# TYPE_RANGE = 'range'
#     TYPE_CHOICES = ((TYPE_LOCATION, 'Location based'),
#                     (TYPE_RANGE, 'Range based'))
#     TYPE = None
#     TYPE = TYPE_RANGE
#     TYPE = TYPE_LOCATION
#     ACTION_CHOICES = (
#         ('A', 'ALLOW'),
#         ('D', 'DENY')
#     )
# class IPGroupManager(models.Manager):
# class IPGroup(models.Model):
#     class Meta:
# class RangeBasedIPGroup(IPGroup):
#     class Meta:
# class LocationBasedIPGroup(IPGroup):
#     class Meta:
# class IPRange(models.Model):
#     class Meta:
# class IPLocation(models.Model):
#     class Meta:
# class Rule(models.Model):
#     class Meta:
# class ReloadRulesRequest(models.Model):
#     def get_queryset(self):
#     def __init__(self, *args, **kwargs):
#     def load(self):
#     def save(self, *args, **kwargs):
#     def __str__(self):
# def typed_ip_group(ip_group):
#     def load_ranges(self):
#     def ranges(self, ip_type=None):
#     def matches(self, ip):
#     def details_str(self):
#     def load_locations(self):
#     def matches(self, ip):
#     def details_str(self):
#     def start(self):
#     def end(self):
#     def ip_type(self):
#     def __contains__(self, ip):
#     def __str__(self):
#     def __contains__(self, country_code):
#     def __str__(self):
#     def __init__(self, *args, **kwargs):
#     def regex(self):
#     def matches_url(self, url):
#     def matches_ip(self, ip):
#     def is_restricted(self):
#     def is_allowed(self):
#     def action_str(self):
#     def swap_with_rule(self, other):
#     def move_up(self):
#     def move_up_url(self):
#     def move_down_url(self):
#     def move_down(self):
#     def save(self, *args, **kwargs):
#     def request_reload(cls):
#     def last_request():
# 
# Path: iprestrict/geoip.py
# NO_COUNTRY = 'XX'


# Path: tests/test_admin.py
from django.test import TestCase
from iprestrict import admin, models
from iprestrict.geoip import NO_COUNTRY

        self.assertIn("cidr_prefix_length", form.errors)
        self.assertIn("Must be a number between", "\n".join(form.errors["cidr_prefix_length"]))

    def test_cidr_prefix_length_for_ipv6(self):
        form_data = {
            "ip_group": self.all_group.pk,
            "first_ip": "::1",
            "cidr_prefix_length": 127,
        }
        form = admin.IPRangeForm(data=form_data)
        self.assertTrue(form.is_valid())

    def test_ipv6_cidr_prefix_length_invalid(self):
        form_data = {
            "ip_group": self.all_group.pk,
            "first_ip": "::1",
            "cidr_prefix_length": 130,
        }
        form = admin.IPRangeForm(data=form_data)
        self.assertFalse(form.is_valid())
        self.assertIn("cidr_prefix_length", form.errors)
        self.assertIn("Must be a number between", "\n".join(form.errors["cidr_prefix_length"]))


    def test_ip_types(self):
        form_data = {
            "ip_group": self.all_group.pk,
            "first_ip": "192.168.1.1",
            "last_ip": "fe80::9eeb:e8ff:fe0e:8a21",
        }

        form = admin.IPRangeForm(data=form_data)