Skip to content

Commit

Permalink
Merge pull request FaradayRF#46 from kb1lqc/serialTestClass
Browse files Browse the repository at this point in the history
Remove serialtestclass.py Dependency
  • Loading branch information
kb1lqc authored Feb 27, 2018
2 parents 0dace24 + f5eb1cc commit 9de656b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 30 deletions.
17 changes: 0 additions & 17 deletions tests/serialtestclass.py

This file was deleted.

12 changes: 6 additions & 6 deletions tests/test_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import string

from faradayio import faraday
from tests.serialtestclass import SerialTestClass
# from tests.serialtestclass import SerialTestClass


def test_socketOne():
"""Simple test to make sure loopback serial port created successfully"""
serialPort = SerialTestClass()
serialInstance = faraday.SerialTestClass()
testStr = "Hello World!"
serialPort.serialPort.write(testStr.encode(encoding='utf_8'))
res = serialPort.serialPort.read(len(testStr))
serialInstance.serialPort.write(testStr.encode(encoding='utf_8'))
res = serialInstance.serialPort.read(len(testStr))

assert res.decode("utf-8") == testStr

Expand All @@ -36,7 +36,7 @@ def test_socketOne():
])
def test_serialParamaterizedSynchSend(test_input):
# Create class object necessary for test
serialInstance = SerialTestClass()
serialInstance = faraday.SerialTestClass()
faradayRadio = faraday.Faraday(serialInstance.serialPort)

# Create slip message to test against
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_serialParamaterizedSynchReceive(test_input):
"""

# Create class object necessary for test
serialInstance = SerialTestClass()
serialInstance = faraday.SerialTestClass()
slip = sliplib.Driver()
faradayRadio = faraday.Faraday(serialInstance.serialPort)

Expand Down
17 changes: 10 additions & 7 deletions tests/test_tun.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import threading

from faradayio import faraday
from tests.serialtestclass import SerialTestClass
from scapy.all import UDP, IP, sendp


def test_tunSetup():
"""Setup a Faraday TUN and check initialized values"""

# Create a test serial port
serialPort = SerialTestClass()
serialInstance = faraday.SerialTestClass()
serialPort = serialInstance.serialPort

# Create test TUN monitor which sets up a python-pytun TUN device at _TUN
isRunning = threading.Event()
Expand All @@ -33,7 +33,8 @@ def test_tunSend():
data and check that the IP payload is valid with scapy.
"""
# Create a test serial port
serialPort = SerialTestClass()
serialInstance = faraday.SerialTestClass()
serialPort = serialInstance.serialPort

# Create test TUN monitor which sets up a python-pytun TUN device at _TUN
isRunning = threading.Event()
Expand Down Expand Up @@ -86,7 +87,8 @@ def test_tunSlipSend():
to TUN/IP nor IP to TUN data validation.
"""
# Create a test serial port
serialPort = SerialTestClass()
serialInstance = faraday.SerialTestClass()
serialPort = serialInstance.serialPort

# Configure destination IP:port
destHost = '10.0.0.2'
Expand All @@ -95,7 +97,7 @@ def test_tunSlipSend():
# Start the monitor
isRunning = threading.Event()
isRunning.set()
TUNMonitor = faraday.Monitor(serialPort=serialPort.serialPort,
TUNMonitor = faraday.Monitor(serialPort=serialPort,
isRunning=isRunning)

# Create an IP packet to send from TUN IP:port (arbitrary) to dest IP:port
Expand Down Expand Up @@ -146,7 +148,8 @@ def test_serialToTUN():
SLIP. Send it to the TUN and verify that the IP:PORT receives the message.
"""
# Create a test serial port for TUN Monitor class. Won't be used.
serialPort = SerialTestClass()
serialInstance = faraday.SerialTestClass()
serialPort = serialInstance.serialPort

# Configure TUN IP:PORT and IP Packet source IP:PORT parameters for test
sourceAddress = '10.0.0.2'
Expand All @@ -156,7 +159,7 @@ def test_serialToTUN():
# Start a TUN Monitor class
isRunning = threading.Event()
isRunning.set()
TUNMonitor = faraday.Monitor(serialPort=serialPort.serialPort,
TUNMonitor = faraday.Monitor(serialPort=serialPort,
isRunning=isRunning)

# Open a socket for UDP packets and bind it to the TUN address:port
Expand Down

0 comments on commit 9de656b

Please sign in to comment.