Skip to content

Commit

Permalink
Merge 3970177 into 5442125
Browse files Browse the repository at this point in the history
  • Loading branch information
lamenezes committed Feb 21, 2021
2 parents 5442125 + 3970177 commit f435de3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dojo_toolkit/code_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def on_modified(self, event):
"""

if not self.dojo.round_started:
self.handle_stopped_round()
return self.handle_stopped_round()

if self.get_last_test_run_interval() < self.min_test_time_interval:
return
Expand Down
11 changes: 4 additions & 7 deletions dojo_toolkit/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@ def run(self):
)
process.wait()

success = process.returncode == 0
self.handle_result(success)
if os.name == "nt":
command = "cls"
else:
command = "clear"
is_success = process.returncode == 0
self.handle_result(is_success)
command = "cls" if os.name == "nt" else "clear"
tmp = call(command, shell=True) # noqa
print('\n'.join(str(line) for line in process.stdout.readlines()))

return success
return is_success

def handle_result(self, success):
if success:
Expand Down
15 changes: 15 additions & 0 deletions tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,22 @@ def test_code_handler_on_modified_tests_fail(get_interval, mocked_code_handler):
assert mocked_code_handler.test_runner.run.called


@mock.patch('dojo_toolkit.code_handler.DojoCodeHandler.get_last_test_run_interval')
@mock.patch('dojo_toolkit.code_handler.notifier')
def test_code_handler_on_modified_and_round_stopped(
notifier_mock, get_interval_mock, mocked_code_handler
):
mocked_code_handler.dojo.round_started = False
get_interval_mock.return_value = 1234

mocked_code_handler.on_modified(mock.Mock())

notifier_mock.notify.assert_called_once_with('Round has not been started')
assert get_interval_mock.call_count == 0


@mock.patch('dojo_toolkit.code_handler.notifier')
def test_code_handler_handle_stopped_round(notifier, mocked_code_handler):
mocked_code_handler.handle_stopped_round()

assert notifier.notify.called

0 comments on commit f435de3

Please sign in to comment.