-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addition of additional tests. Additions of waiting for commands in "P…
…ushManager". Bug fixes in "ConsoleManager". Small changes.
- Loading branch information
Showing
9 changed files
with
144 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
import sys | ||
import tkinter | ||
|
||
sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), '../../../sources/Overwatch Rank Tracker'))) | ||
import MainWindow # noqa: E402 | ||
|
||
|
||
def test_center_window(): | ||
"""Check that the window is created in the center of the screen.""" | ||
|
||
# create window | ||
test_window = tkinter.Tk() | ||
|
||
# calling window centering function | ||
MainWindow.MainWindow.center_window(window=test_window, window_height=123, window_width=456) | ||
|
||
# getting window coordinates after centering | ||
x_coord = test_window.winfo_x() | ||
y_coord = test_window.winfo_y() | ||
|
||
assert (x_coord, y_coord) == (0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
import sys | ||
import tkinter | ||
from unittest.mock import patch | ||
from tkinter import ttk # noqa: F401 | ||
|
||
sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), '../../../sources/Overwatch Rank Tracker'))) | ||
import MainWindow # noqa: E402 | ||
|
||
|
||
def setup_main_window_with_mock(): | ||
"""Running the 'create_and_configure_window' function using mocking, | ||
as the 'iconphoto' method cannot be called within unit testing, due to the absence of an actual application window.""" | ||
|
||
# creating an instance of a class | ||
mainWindow = MainWindow.MainWindow() | ||
|
||
# since there is no actual window in the tests, the "iconphoto" method cannot be applied, so it is mocked here | ||
with patch.object(tkinter.Tk, 'iconphoto'): | ||
mainWindow.create_and_configure_window() | ||
|
||
return mainWindow | ||
|
||
|
||
def test_window_created(): | ||
"""Checking that the window is actually created.""" | ||
|
||
mainWindow = setup_main_window_with_mock() | ||
assert isinstance(mainWindow.main_window, tkinter.Tk) | ||
|
||
|
||
def test_window_title(): | ||
"""Checking that the window has the desired name.""" | ||
|
||
mainWindow = setup_main_window_with_mock() | ||
assert mainWindow.main_window.title() == 'Overwatch Rank Tracker' | ||
|
||
|
||
def test_window_style(): | ||
"""Checking that the styles have been configured correctly.""" | ||
|
||
mainWindow = setup_main_window_with_mock() | ||
|
||
# get styles | ||
style = tkinter.ttk.Style(mainWindow.main_window) | ||
actual_styles = {'background': style.lookup('Treeview', 'background'), 'foreground': style.lookup('Treeview', 'foreground'), 'fieldbackground': style.lookup('Treeview', 'fieldbackground')} | ||
expected_styles = {'background': '#2B2B2B', 'foreground': 'white', 'fieldbackground': '#2B2B2B'} | ||
|
||
assert actual_styles == expected_styles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), '../../../sources/Overwatch Rank Tracker'))) | ||
import FileManager # noqa: E402 | ||
|
||
|
||
path_to_file_test = os.path.abspath(os.path.join(__file__, '../../test_settings_and_battle_tags.json')) | ||
|
||
|
||
def test_set_settings_value_change(): | ||
"""Checks for changes to settings variables after using the "set_settings" function.""" | ||
|
||
# define a class | ||
filemanager = FileManager.FileManager() | ||
|
||
# value change | ||
filemanager.path_to_file = path_to_file_test | ||
filemanager.max_workers = 3 | ||
|
||
# create file | ||
filemanager.overwriting_file(full_rewrite=True) | ||
|
||
# value change, max_workers in file = 3, in class = 6 | ||
filemanager.max_workers = 6 | ||
|
||
# set settings, max_workers should now be set to 2 | ||
filemanager.set_settings() | ||
|
||
# delete file | ||
os.remove(path_to_file_test) | ||
|
||
assert filemanager.max_workers == 3 | ||
|
||
|
||
def test_set_settings_no_file(): | ||
"""Checks that after using the "set_settings" function a file with settings is created, if it was not there before.""" | ||
|
||
# define a class | ||
filemanager = FileManager.FileManager() | ||
|
||
# value change | ||
filemanager.path_to_file = path_to_file_test | ||
|
||
# set settings, max_workers should now be set to 2 | ||
filemanager.set_settings() | ||
|
||
assert os.path.exists(filemanager.path_to_file) | ||
|
||
# delete file | ||
os.remove(path_to_file_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters