<commit_before># -*- coding: utf-8 -*-

# Import Python libs
from __future__ import absolute_import

# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.unit import skipIf

# Import Salt Libs
import salt.utils

URL = 'repo.saltstack.com'


class NetworkTest(ModuleCase):
    '''
    Validate network module
    '''
    def test_network_ping(self):
        '''
        network.ping
        '''
        ret = self.run_function('network.ping', [URL])
        exp_out = ['ping', URL, 'ttl', 'time']
        for out in exp_out:
            self.assertIn(out, ret.lower())

    def test_network_netstat(self):
        '''
        network.netstat
        '''
        ret = self.run_function('network.netstat')
        exp_out = ['proto', 'local-address']
        for val in ret:
            for out in exp_out:
                self.assertIn(out, val)

    def test_network_traceroute(self):
        '''
        network.traceroute
        '''
        if not salt.utils.which('traceroute') and not salt.utils.is_windows():
            self.skipTest('traceroute not installed')
        ret = self.run_function('network.traceroute', [URL])
        exp_out = ['hostname', 'ip']
        for out in exp_out:
            self.assertIn(out, exp_out)

    @skipIf(not salt.utils.is_windows(), 'windows only test')
    def test_network_nslookup(self):
        '''
        network.nslookup<commit_msg>Skip netstat test on macosx as its not supported<commit_after># -*- coding: utf-8 -*-

# Import Python libs
from __future__ import absolute_import

# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.unit import skipIf

# Import Salt Libs
import salt.utils

URL = 'repo.saltstack.com'


class NetworkTest(ModuleCase):
    '''
    Validate network module
    '''
    def test_network_ping(self):
        '''
        network.ping
        '''
        ret = self.run_function('network.ping', [URL])
        exp_out = ['ping', URL, 'ttl', 'time']
        for out in exp_out:
            self.assertIn(out, ret.lower())

    @skipIf(salt.utils.is_darwin(), 'not supported on macosx')
    def test_network_netstat(self):
        '''
        network.netstat
        '''
        ret = self.run_function('network.netstat')
        exp_out = ['proto', 'local-address']
        for val in ret:
            for out in exp_out:
                self.assertIn(out, val)

    def test_network_traceroute(self):
        '''
        network.traceroute
        '''
        if not salt.utils.which('traceroute') and not salt.utils.is_windows():
            self.skipTest('traceroute not installed')
        ret = self.run_function('network.traceroute', [URL])
        exp_out = ['hostname', 'ip']
        for out in exp_out:
            self.assertIn(out, exp_out)

    @skipIf(not salt.utils.is_windows(), 'windows only test')
    def test_network_nslookup(self):
        '''
        network.nslookup
{'fraction_non_alphanumeric': 0.12065439672801637, 'fraction_numerical': 0.0006816632583503749, 'mean_word_length': 2.3504566210045663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2222677', 'n_tokens_mistral': 898, 'n_tokens_neox': 878, 'n_words': 214}