Skip to content

Commit

Permalink
Increased coverage on tests and completed checks on others to
Browse files Browse the repository at this point in the history
    ensure the tests ran successfully
  • Loading branch information
MosesofEgypt committed Jun 19, 2017
1 parent 3b64601 commit 162936b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
47 changes: 32 additions & 15 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"""


def should_not_be_run(*args, **kwargs):
raise Exception("The line of code should have not been run.")


class RotatingFileHandlerMock(RotatingFileHandler):

def doRollover(self):
Expand Down Expand Up @@ -76,7 +80,9 @@ def tearDown(self):
del self.session_mock

def test_directories_are_properly_setup(self):
config.setup_directories()
with mock.patch('os.path.exists', return_value=False) as m1,\
mock.patch('os.makedirs') as m2:
config.setup_directories()

if getattr(sys, 'frozen', False):
BASE_DIR = os.path.dirname(os.path.abspath(sys.executable))
Expand All @@ -99,28 +105,39 @@ def test_directories_are_properly_setup(self):

self.assertTrue(config._DIRECTORIES_SETUP)

def test_loggers_are_properly_setup(self):
# TODO:
# until the bug with the logger can be fixed, the logger wont be setup.
# also need to determine how to detect if it has been set up
def test_loggers_can_be_setup(self):
config._LOGGER_SETUP = False
config.setup_logger()
self.assertTrue(config._LOGGER_SETUP)

def test_loggers_are_not_setup_twice(self):
def test_loggers_cannot_be_setup_twice(self):
config._LOGGER_SETUP = True
config.setup_logger()
# TODO:
# need to determine how to detect if it has been set up
with mock.patch('config.RotatingFileHandler', should_not_be_run) as m:
config.setup_logger()

def test_translations_are_properly_installed(self):
# TODO:
# need to figure out how to determine if they are installed
def test_translations_can_be_installed(self):
config.install_translations()

self.assertTrue(config._TRANSLATIONS_INSTALLED)

def test_translations_cannot_be_installed_twice(self):
config._TRANSLATIONS_INSTALLED = True
with mock.patch('config.get_platform', should_not_be_run) as m:
config.install_translations()

def test_config_can_load_config(self):
config.CONFIG = None
config.setup_logger()
config.setup_directories()
config.install_translations()

resource_config = os.path.join(config.RESOURCE_DIR, config.CONFIG_NAME)
def resource_exists_mock(path):
return path == resource_config

with mock.patch('config.open', mock.mock_open(
read_data=config_test_data)) as m:
read_data=config_test_data)) as m1,\
mock.patch('os.path.exists', resource_exists_mock) as m2,\
mock.patch('shutil.copyfile') as m3:
config.load_config()

session = self.session_mock
Expand All @@ -129,7 +146,7 @@ def test_config_can_load_config(self):
"https://patch.houraiteahouse.net/fantasy-crescendo/"
"launcher/config.json", responses)

m.assert_called_once_with(
m1.assert_called_once_with(
os.path.join(config.CONFIG_DIR, config.CONFIG_NAME), 'r+')

def test_config_contains_proper_attributes(self):
Expand Down
2 changes: 0 additions & 2 deletions test/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ def test_download_tracker_updates_properly(self):
self.download_tracker.progress_bar = None
self.download_tracker.update()

# TODO:
# write unittests for run, and run_async
def test_download_tracker_can_execute_requests(self):
tracker = self.download_tracker
test_download_1 = Download('', '', 2048)
Expand Down
2 changes: 0 additions & 2 deletions test/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ def test_main_window_can_initialize_ui(self):
self.assertTrue(hasattr(main_window, "download_tracker"))
self.assertTrue(hasattr(main_window, "download_tracker"))

# TODO: maybe determine if the widgets are set up properly?

def test_main_window_can_launch_game(self):
launch_args = []
system = get_platform()
Expand Down

0 comments on commit 162936b

Please sign in to comment.