|
8 | 8 | Tests for `planemo` module. |
9 | 9 | """ |
10 | 10 |
|
11 | | -from click.testing import CliRunner |
| 11 | +from .test_utils import CliTestCase |
| 12 | +from .test_utils import main |
12 | 13 |
|
13 | | -import unittest |
14 | 14 |
|
15 | | -from planemo import cli |
16 | | - |
17 | | - |
18 | | -# More information on testing click applications at following link. |
19 | | -# http://click.pocoo.org/3/testing/#basic-testing |
20 | | -class TestPlanemo(unittest.TestCase): |
| 15 | +class TestPlanemo(CliTestCase): |
21 | 16 |
|
22 | 17 | def test_commands_have_help(self): |
23 | | - commands = cli.list_cmds() |
24 | | - runner = CliRunner() |
| 18 | + commands = self._cli.list_cmds() |
25 | 19 | for command in commands: |
26 | | - planemo_cli = cli.planemo |
27 | | - result = runner.invoke(planemo_cli, [command, "--help"]) |
28 | | - if result.exit_code != 0: |
29 | | - message = "Planemo command %s has invalid --help." % command |
30 | | - raise AssertionError(message) |
| 20 | + self._check_exit_code([command, "--help"]) |
31 | 21 |
|
32 | 22 | def test_responds_to_desired_commands(self): |
33 | | - commands = cli.list_cmds() |
| 23 | + commands = self._cli.list_cmds() |
34 | 24 |
|
35 | 25 | def assert_responds_to(command): |
36 | 26 | assert command in commands, "No command %s" % command |
37 | 27 |
|
38 | | - assert_responds_to("docker_shell") |
39 | | - assert_responds_to("docker_build") |
40 | 28 | assert_responds_to("brew_init") |
41 | 29 | assert_responds_to("brew") |
42 | 30 | assert_responds_to("brew_env") |
43 | 31 | assert_responds_to("config_init") |
| 32 | + assert_responds_to("create_gist") |
| 33 | + assert_responds_to("docker_build") |
| 34 | + assert_responds_to("docker_shell") |
44 | 35 | assert_responds_to("lint") |
| 36 | + assert_responds_to("normalize") |
45 | 37 | assert_responds_to("project_init") |
46 | | - assert_responds_to("shed_upload") |
47 | 38 | assert_responds_to("serve") |
| 39 | + assert_responds_to("shed_diff") |
| 40 | + assert_responds_to("shed_download") |
| 41 | + assert_responds_to("shed_upload") |
48 | 42 | assert_responds_to("syntax") |
49 | 43 | assert_responds_to("test") |
| 44 | + assert_responds_to("tool_factory") |
| 45 | + assert_responds_to("tool_init") |
50 | 46 | assert_responds_to("travis_before_install") |
51 | 47 | assert_responds_to("travis_init") |
52 | 48 |
|
| 49 | + def test_planemo_version_command(self): |
| 50 | + self._check_exit_code(["--version"]) |
| 51 | + |
| 52 | + def test_planemo_help_command(self): |
| 53 | + self._check_exit_code(["--help"]) |
| 54 | + |
53 | 55 |
|
54 | 56 | if __name__ == '__main__': |
55 | | - unittest.main() |
| 57 | + main() |
0 commit comments