# Path: katprep/network.py
# def is_ipv4(address):
#     """
#     Returns whether the supplied address is a valid IPv4 address
# 
#     :param address: IP address
#     :type address: str
#     """
#     # Friendly inspired by: https://stackoverflow.com/questions/319279/
#     # how-to-validate-ip-address-in-python
#     try:
#         socket.inet_pton(socket.AF_INET, address)
#     except AttributeError:
#         try:
#             socket.inet_aton(address)
#         except socket.error:
#             return False
#         return address.count(".") == 3
#     except socket.error:
#         return False
#     return True
# 
# Path: tests/utilities.py
# def load_config(config_file):
#     if not os.path.isfile(config_file):
#         pytest.skip("Please create configuration file %s!" % config_file)
# 
#     try:
#         with open(config_file, "r") as json_file:
#             return json.load(json_file)
#     except IOError as err:
#         pytest.skip("Unable to read configuration file: '%s'", err)


import logging
import mock
import pytest
import ssl
from katprep.network import is_ipv4
from .utilities import load_config



@pytest.mark.parametrize("address", [
    '192.168.0.1',
    '12.34.56.78',
    pytest.param('no', marks=pytest.mark.xfail),
    pytest.param('1.2.3', marks=pytest.mark.xfail),
    pytest.param('1.2.3.4.5', marks=pytest.mark.xfail),
    pytest.param('1.2.3.4', marks=pytest.mark.xfail),
])
def test_ipv4_check(address):
    "Making sure we are able to identify an IPv4 address"

# Path: katprep/network.py
# def is_ipv4(address):
#     """
#     Returns whether the supplied address is a valid IPv4 address
# 
#     :param address: IP address
#     :type address: str
#     """
#     # Friendly inspired by: https://stackoverflow.com/questions/319279/
#     # how-to-validate-ip-address-in-python
#     try:
#         socket.inet_pton(socket.AF_INET, address)
#     except AttributeError:
#         try:
#             socket.inet_aton(address)
#         except socket.error:
#             return False
#         return address.count(".") == 3
#     except socket.error:
#         return False
#     return True
# 
# Path: tests/utilities.py
# def load_config(config_file):
#     if not os.path.isfile(config_file):
#         pytest.skip("Please create configuration file %s!" % config_file)
# 
#     try:
#         with open(config_file, "r") as json_file:
#             return json.load(json_file)
#     except IOError as err:
#         pytest.skip("Unable to read configuration file: '%s'", err)


# Path: tests/test_network_utilities.py
import logging
import mock
import pytest
import ssl
from katprep.network import is_ipv4
from .utilities import load_config




@pytest.mark.parametrize("address", [
    '192.168.0.1',
    '12.34.56.78',
    pytest.param('no', marks=pytest.mark.xfail),
    pytest.param('1.2.3', marks=pytest.mark.xfail),
    pytest.param('1.2.3.4.5', marks=pytest.mark.xfail),
    pytest.param('1.2.3.4', marks=pytest.mark.xfail),
])
def test_ipv4_check(address):
    "Making sure we are able to identify an IPv4 address"

    assert is_ipv4(address)