This repository was archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
/
Copy pathtest_make_command.py
46 lines (35 loc) · 1.74 KB
/
test_make_command.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
import os
from flexmock import flexmock
from orator.migrations import MigrationCreator
from orator.commands.migrations import MigrateMakeCommand
from .. import OratorCommandTestCase
class MigrateMakeCommandTestCase(OratorCommandTestCase):
def test_basic_create_gives_creator_proper_arguments(self):
creator_mock = flexmock(MigrationCreator)
creator_mock.should_receive("create").once().with_args(
"create_foo", os.path.join(os.getcwd(), "migrations"), None, False
).and_return("foo")
command = flexmock(MigrateMakeCommand())
command.should_receive("_get_config").and_return({})
self.run_command(command, [("name", "create_foo")])
def test_basic_create_gives_creator_proper_arguments_when_table_is_set(self):
creator_mock = flexmock(MigrationCreator)
creator_mock.should_receive("create").once().with_args(
"create_foo", os.path.join(os.getcwd(), "migrations"), "users", False
).and_return("foo")
command = flexmock(MigrateMakeCommand())
command.should_receive("_get_config").and_return({})
self.run_command(command, [("name", "create_foo"), ("--table", "users")])
def test_basic_create_gives_creator_proper_arguments_when_table_is_set_with_create(
self,
):
creator_mock = flexmock(MigrationCreator)
creator_mock.should_receive("create").once().with_args(
"create_foo", os.path.join(os.getcwd(), "migrations"), "users", True
).and_return("foo")
command = flexmock(MigrateMakeCommand())
command.should_receive("_get_config").and_return({})
self.run_command(
command, [("name", "create_foo"), ("--table", "users"), "--create"]
)