Skip to content

Commit

Permalink
Add tests for timeout running actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaume Florez committed Jan 19, 2018
1 parent 81d8f21 commit 8846742
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spec/format_parser_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,45 @@

logging.stop()

with it('must timout running all actions'):
default_conf = {
'github_token': 'GHT',
'gitlab_token': 'GLT',
'vhost_path': 'VHP'
}
webhook_data_path = join(
data_path, join('webhook', 'default_event')
)
with open(
join(data_path, 'utils', 'async_timeout.log'), 'r'
) as log_file:
expected_log = log_file.read()
with patch('hookshub.parser.logging') as logging:
logging.start()
logging.basicConfig.return_value = True
logging.info = True
logger = Mock()
logger.info.return_value = True
logger.error.return_value = True
logging.getLogger.return_value = logger
with patch('hookshub.parser.Pool') as pooler:
proc = Mock()
proc.wait.return_value = True
proc.ready.return_value = False

pool = Mock()
pool.apply_async.return_value = proc

pooler.start()
pooler.return_value = pool
parser = HookParser(webhook_data_path,
event='default_event',
procs=1)
res = parser.run_event_actions(def_conf=default_conf)
expect(res).to(equal(
(0, expected_log)
))

with context('Load Hooks (Plugins):'):
with it('must get a list of hooks from HooksManager'):
with patch('hookshub.hook.get_hooks') as get_hook_mock:
Expand Down
4 changes: 4 additions & 0 deletions test_data/utils/async_timeout.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[default_event.py]:[default_event.py]:ProcOut:
Still running async, but answering. Check log for detailed result...[default_event.py]:ProcErr:
Still running async, but answering. Check log for detailed result...
[default_event.py]:Success!

0 comments on commit 8846742

Please sign in to comment.