"""
Test module for app.py

Created on 20 December 2018
@author: Charlie Lewis
"""
import pytest
import sys

from .app import run_p0f
from .app import run_tshark
from .app import parse_output
from .app import connect
from .app import save
from .app import main


def test_run_p0f():
    with open('/tmp/test', 'w') as f:
        f.write("this is an invalid test file")
    sys.argv = ['/tmp/test']
    run_p0f()


def test_run_tshark():
    with open('/tmp/test', 'w') as f:
        f.write("this is an invalid test file")
    sys.argv = ['/tmp/test']
    run_tshark()


def test_parse_output():
    with open('/tmp/test', 'w') as f:
        f.write("this is an invalid test file")
    sys.argv = ['/tmp/test']
    run_p0f()
    run_tshark()
    parse_output()


def test_connect():
    r = connect()
    assert r != None


def test_save():
    results = {'foo':{'bar':'baz'}}
    save(results)
    results = [{'foo':{'bar':'baz'}}]
    save(results)


def test_main():
    with open('/tmp/test', 'w') as f:
        f.write("this is an invalid test file")
    sys.argv = ['/tmp/test']
    main()

@@ -370,32 +370,39 @@
     sys.argv = %5B
+'p0f', 
 '/tmp/test'%5D%0A   
@@ -390,32 +390,32 @@
 ', '/tmp/test'%5D%0A
-
     run_p0f()%0A%0A%0A
@@ -531,32 +531,39 @@
     sys.argv = %5B
+'p0f', 
 '/tmp/test'%5D%0A   
@@ -697,32 +697,39 @@
     sys.argv = %5B
+'p0f', 
 '/tmp/test'%5D%0A   
@@ -851,24 +851,42 @@
 est_save():%0A
+    r = connect()%0A
     results 
@@ -910,32 +910,35 @@
 baz'%7D%7D%0A    save(
+r, 
 results)%0A    res
@@ -977,16 +977,19 @@
    save(
+r, 
 results)
@@ -1086,32 +1086,32 @@
 lid test file%22)%0A
-
     sys.argv = %5B
@@ -1110,16 +1110,23 @@
 argv = %5B
+'p0f', 
 '/tmp/te

fix tests