| 1 |
from pecan.tests import PecanTestCase |
| 2 |
|
| 3 |
|
| 4 |
class TestCommandManager(PecanTestCase): |
| 5 |
|
| 6 |
def test_commands(self): |
| 7 |
from pecan.commands import ServeCommand, ShellCommand, CreateCommand |
| 8 |
from pecan.commands.base import CommandManager |
| 9 |
m = CommandManager() |
| 10 |
assert m.commands['serve'] == ServeCommand |
| 11 |
assert m.commands['shell'] == ShellCommand |
| 12 |
assert m.commands['create'] == CreateCommand |
| 13 |
|
| 14 |
|
| 15 |
class TestCommandRunner(PecanTestCase): |
| 16 |
|
| 17 |
def test_commands(self): |
| 18 |
from pecan.commands import ( |
| 19 |
ServeCommand, ShellCommand, CreateCommand, CommandRunner |
| 20 |
) |
| 21 |
runner = CommandRunner() |
| 22 |
assert runner.commands['serve'] == ServeCommand |
| 23 |
assert runner.commands['shell'] == ShellCommand |
| 24 |
assert runner.commands['create'] == CreateCommand |
| 25 |
|
| 26 |
def test_run(self): |
| 27 |
from pecan.commands import CommandRunner |
| 28 |
runner = CommandRunner() |
| 29 |
self.assertRaises( |
| 30 |
RuntimeError, |
| 31 |
runner.run, |
| 32 |
['serve', 'missing_file.py'] |
| 33 |
) |
| 34 |
|
| 35 |
|
| 36 |
class TestCreateCommand(PecanTestCase): |
| 37 |
|
| 38 |
def test_run(self): |
| 39 |
from pecan.commands import CreateCommand |
| 40 |
|
| 41 |
class FakeArg(object): |
| 42 |
project_name = 'default' |
| 43 |
template_name = 'default' |
| 44 |
|
| 45 |
class FakeScaffold(object): |
| 46 |
def copy_to(self, project_name): |
| 47 |
assert project_name == 'default' |
| 48 |
|
| 49 |
class FakeManager(object): |
| 50 |
scaffolds = { |
| 51 |
'default': FakeScaffold |
| 52 |
} |
| 53 |
|
| 54 |
c = CreateCommand() |
| 55 |
c.manager = FakeManager() |
| 56 |
c.run(FakeArg()) |