# Path: mastermind/networksetup.py
# def service_map(service_order):
#     return re.findall(r'\(\d+\)\s(.*)$\n\(.*Device: (.+)\)$',
#                       service_order,
#                       re.MULTILINE)
# 
# def webproxy_record(raw_record):
#     return dict(map(lambda x: x.split(': '), raw_record.splitlines()))
# 
# def is_proxy_enabled(record):
#     return record['Enabled'] == 'Yes'


from mastermind.networksetup import (service_map,
                                     webproxy_record,
                                     is_proxy_enabled)
                ('AirCard 782S', 'en5'),
                ('Bluetooth PAN', 'en4'),
                ('Thunderbolt Bridge', 'bridge0')]

    assert service_map(mock_service_order) == expected


def test_webproxy_record():
    mock_raw_record = """Enabled: No
Server: 127.0.0.1
Port: 8080
Authenticated Proxy Enabled: 0"""
    expected = {'Authenticated Proxy Enabled': '0',
                'Enabled': 'No',
                'Port': '8080',
                'Server': '127.0.0.1'}

    assert webproxy_record(mock_raw_record) == expected


def test_is_proxy_enabled():
    mock_record_disabled = {'Authenticated Proxy Enabled': '0',
                            'Enabled': 'No',
                            'Port': '8080',
                            'Server': '127.0.0.1'}
    mock_record_enabled = {'Authenticated Proxy Enabled': '0',
                           'Enabled': 'Yes',
                           'Port': '8080',
                           'Server': '127.0.0.1'}
    assert is_proxy_enabled(mock_record_disabled) is False

# Path: mastermind/networksetup.py
# def service_map(service_order):
#     return re.findall(r'\(\d+\)\s(.*)$\n\(.*Device: (.+)\)$',
#                       service_order,
#                       re.MULTILINE)
# 
# def webproxy_record(raw_record):
#     return dict(map(lambda x: x.split(': '), raw_record.splitlines()))
# 
# def is_proxy_enabled(record):
#     return record['Enabled'] == 'Yes'


# Path: test/test_networksetup.py
from mastermind.networksetup import (service_map,
                                     webproxy_record,
                                     is_proxy_enabled)

                ('AirCard 782S', 'en5'),
                ('Bluetooth PAN', 'en4'),
                ('Thunderbolt Bridge', 'bridge0')]

    assert service_map(mock_service_order) == expected


def test_webproxy_record():
    mock_raw_record = """Enabled: No
Server: 127.0.0.1
Port: 8080
Authenticated Proxy Enabled: 0"""
    expected = {'Authenticated Proxy Enabled': '0',
                'Enabled': 'No',
                'Port': '8080',
                'Server': '127.0.0.1'}

    assert webproxy_record(mock_raw_record) == expected


def test_is_proxy_enabled():
    mock_record_disabled = {'Authenticated Proxy Enabled': '0',
                            'Enabled': 'No',
                            'Port': '8080',
                            'Server': '127.0.0.1'}
    mock_record_enabled = {'Authenticated Proxy Enabled': '0',
                           'Enabled': 'Yes',
                           'Port': '8080',
                           'Server': '127.0.0.1'}
    assert is_proxy_enabled(mock_record_disabled) is False

    assert is_proxy_enabled(mock_record_enabled) is True