def test_is_pcap(self): """Test is_pcap function""" FILE = os.path.join('tests', 'test.pcap') test = pcap2map.Pcap2Map() test.is_pcap(FILE) # Check that non pcap file raises exception FILE = os.path.join('tests', 'test.xls') test = pcap2map.Pcap2Map() with pytest.raises(Exception): test.is_pcap(FILE)
def test_log_function(self): """Test log_function function""" # Set command line arguments for testing purposes input_file_arg = os.path.join('tests', 'test.pcap') sys.argv = ['pcap2map.py', input_file_arg] test = pcap2map.Pcap2Map() test.log_function()
def test_png_path_func(self): """Test png_path function""" FILE = os.path.join('tests', 'test.pcap') PNG_PATH = None test = pcap2map.Pcap2Map() path = test.png_path_func(FILE, PNG_PATH) assert path == os.path.join('images', 'ip_map_test.png') FILE = os.path.join('tests', 'test.pcap') PNG_PATH = 'tests' test = pcap2map.Pcap2Map() path = test.png_path_func(FILE, PNG_PATH) assert path == os.path.join('tests', 'images', 'ip_map_test.png')
def test_pcap2map(self): """Test pcap2map entire pipeline""" # Set command line arguments for testing purposes input_file_arg = os.path.join('tests', 'test.pcap') sys.argv = ['pcap2map.py', input_file_arg] test = pcap2map.Pcap2Map() # Get command line arguments FILE, PNG_PATH = test.get_args() # Run main function test.run(FILE, PNG_PATH)
def test_getargs(self): """Test get_args function""" # Set command line arguments for testing purposes input_file_arg = os.path.join('tests', 'test.pcap') sys.argv = ['pcap2map.py', input_file_arg] test = pcap2map.Pcap2Map() FILE, PNG_PATH = test.get_args() assert FILE == os.path.join('tests', 'test.pcap') assert PNG_PATH is None png_file_arg = os.path.join('tests', 'test.png') sys.argv = ['pcap2map.py', input_file_arg, '--png_path', png_file_arg] test = pcap2map.Pcap2Map() FILE, PNG_PATH = test.get_args() assert FILE == os.path.join('tests', 'test.pcap') assert PNG_PATH == os.path.join('tests', 'test.png')