-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_application.py
69 lines (54 loc) · 2.15 KB
/
test_application.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# app core modules
from modules.app.gui import Gui
from modules.app.read_write import ReadWrite
from modules.app.settings import Settings
# import GUI modules
from modules.gui.create_files import *
from modules.gui.share_files import *
from modules.gui.view_files import *
from modules.gui.encrypt_files import *
from modules.gui.decrypt_files import *
# testing
import pytest
from main import Application
from modules.tcp import TCP
@pytest.fixture
def app_instance():
return Application( pytest=True )
def test_module_instances( app_instance ):
"""Test if modules are set and match the correct class data type"""
assert isinstance( app_instance.settings, Settings )
# app specific modules
assert isinstance( app_instance.tcp, TCP )
assert isinstance( app_instance.read_write, ReadWrite )
assert isinstance( app_instance.tk_root, Gui )
app_instance.tk_root.destroy()
def test_gui_frames( app_instance ):
"""Test if gui frames/pages class match the required order"""
num_frames = len(app_instance.tk_root.frames)
print( f"Num frames: {num_frames}" )
frames_class = [ GUI_CreateFiles ,
GUI_ShareFiles,
GUI_ViewFiles,
GUI_EncryptFiles,
GUI_DecryptFiles ]
for i in range(0, num_frames):
assert isinstance( app_instance.tk_root.frames[i], frames_class[i] )
def test_tcp_pint( app_instance ):
"""Test basic ping and verify type"""
ping = app_instance.tcp.ping_device( '127.0.0.1' )
print(f"Able to ping myself: {ping}")
assert isinstance( ping, bool )
# read-write
def test_read_write_hasShareableFiles( app_instance ):
"""Verify output type"""
output = app_instance.read_write.hasShareableFiles()
assert isinstance( output, bool )
def test_read_write_getShareableFiles( app_instance ):
"""Verify output type"""
output = app_instance.read_write.getShareableFiles()
assert isinstance( output, list )
def test_read_write_numShareableFiles( app_instance ):
"""Verify output type"""
output = app_instance.read_write.numShareableFiles
assert isinstance( output, int )