__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
import pytest

from netaddr.ip import IPNetwork
from netaddr.contrib.subnet_splitter import SubnetSplitter


def test_ip_splitter():
    splitter = SubnetSplitter('172.24.0.0/16')
    assert splitter.available_subnets() == [IPNetwork('172.24.0.0/16')]

    assert splitter.extract_subnet(23, count=4) == [
        IPNetwork('172.24.0.0/23'),
        IPNetwork('172.24.2.0/23'),
        IPNetwork('172.24.4.0/23'),
        IPNetwork('172.24.6.0/23'),
    ]

    assert splitter.available_subnets() == [
        IPNetwork('172.24.8.0/21'),
        IPNetwork('172.24.16.0/20'),
        IPNetwork('172.24.32.0/19'),
        IPNetwork('172.24.64.0/18'),
        IPNetwork('172.24.128.0/17'),
    ]

    assert splitter.extract_subnet(28, count=10) == [
        IPNetwork('172.24.8.0/28'),
        IPNetwork('172.24.8.16/28'),
        IPNetwork('172.24.8.32/28'),
        IPNetwork('172.24.8.48/28'),
        IPNetwork('172.24.8.64/28'),
        IPNetwork('172.24.8.80/28'),
        IPNetwork('172.24.8.96/28'),
        IPNetwork('172.24.8.112/28'),
        IPNetwork('172.24.8.128/28'),
        IPNetwork('172.24.8.144/28'),
    ]

    splitter.available_subnets() == [
        IPNetwork('172.24.8.128/25'),
        IPNetwork('172.24.9.0/24'),
        IPNetwork('172.24.10.0/23'),
        IPNetwork('172.24.12.0/22'),
        IPNetwork('172.24.16.0/20'),
        IPNetwork('172.24.32.0/19'),
        IPNetwork('172.24.64.0/18'),
        IPNetwork('172.24.128.0/17'),
    ]


def test_ip_splitter_remove_same_input_range():
    s = SubnetSplitter('172.24.0.0/16')
    assert s.available_subnets() == [IPNetwork('172.24.0.0/16')]

    assert s.extract_subnet(16, count=1) == [
        IPNetwork('172.24.0.0/16'),
    ]

    assert s.available_subnets() == []


def test_ip_splitter_remove_more_than_input_range():
    s = SubnetSplitter('172.24.0.0/16')
    assert s.available_subnets() == [IPNetwork('172.24.0.0/16')]

    with pytest.raises(ValueError):
        s.extract_subnet(16, count=2)


def test_ip_splitter_remove_prefix_larger_than_input_range():
    s = SubnetSplitter('172.24.0.0/16')
    assert s.available_subnets() == [IPNetwork('172.24.0.0/16')]
    assert s.extract_subnet(15, count=1) == []
    assert s.available_subnets() == [IPNetwork('172.24.0.0/16')]

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 0 B 0644
test_cidr_v4.py File 7.4 KB 0644
test_cidr_v6.py File 4.56 KB 0644
test_dns.py File 320 B 0644
test_ip.py File 625 B 0644
test_ip_categories.py File 4.04 KB 0644
test_ip_comparisons.py File 1.39 KB 0644
test_ip_globs.py File 2.09 KB 0644
test_ip_network_categories.py File 547 B 0644
test_ip_ranges.py File 8.57 KB 0644
test_ip_rfc1924.py File 512 B 0644
test_ip_sets.py File 22.68 KB 0644
test_ip_splitter.py File 2.21 KB 0644
test_ip_v4.py File 15.07 KB 0644
test_ip_v4_v6_conversions.py File 1.22 KB 0644
test_ip_v6.py File 5.95 KB 0644
test_network_ops.py File 2.37 KB 0644
test_nmap.py File 3.62 KB 0644
test_old_specs.py File 6.37 KB 0644
test_platform_osx.py File 5.29 KB 0644
test_socket_module_fallback.py File 1.48 KB 0644
Filemanager