tests: add basic tests for ctl.py
This commit is contained in:
parent
2e12543311
commit
fc9357b1cd
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import pytest
|
||||
import sys
|
||||
import collections
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
|
@ -423,3 +424,23 @@ def test_runjob(pub):
|
|||
assert AfterJob.get(job.id).status == 'registered'
|
||||
call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id)
|
||||
assert AfterJob.get(job.id).status == 'completed'
|
||||
|
||||
|
||||
def test_ctl_print_help(capsys):
|
||||
ctl = wcs.qommon.ctl.Ctl(cmd_prefixes=['wcs.ctl'])
|
||||
with pytest.raises(SystemExit):
|
||||
ctl.print_help()
|
||||
captured = capsys.readouterr()
|
||||
assert 'runscript' in captured.out
|
||||
|
||||
|
||||
def test_ctl_no_command(capsys):
|
||||
ctl = wcs.qommon.ctl.Ctl(cmd_prefixes=['wcs.ctl'])
|
||||
old_argv, sys.argv = sys.argv, ['wcsctl']
|
||||
try:
|
||||
with pytest.raises(SystemExit):
|
||||
ctl.run(None)
|
||||
captured = capsys.readouterr()
|
||||
assert 'error: You must use a command' in captured.err
|
||||
finally:
|
||||
sys.argv = old_argv
|
||||
|
|
Loading…
Reference in New Issue