Skip to content
Snippets Groups Projects
Commit 03220dfd authored by Daniel Yang's avatar Daniel Yang
Browse files

Added trivial test case

parent 2a36bb25
No related branches found
No related tags found
No related merge requests found
import unittest
from scapy.layers.inet import IP, TCP
from unittest.mock import patch
from src.packet_capturing import packet_handler
class TestPacketCapturing(unittest.TestCase):
def test_baseCase(self):
# Create a dummy packet
packet = IP(src = "100.84.6.141", dst = "192.168.1.1") / TCP(dport = 80, sport = 12345, flags = "S")
# Show detailed information about the package
print(packet.show())
# Mockito checks if print was called
with patch('builtins.print') as mock_print:
packet_handler(packet)
mock_print.assert_called_with("Packet captured: 100.84.6.141 -> 192.168.1.1")
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment