Skip to content

Commit 8425c7f

Browse files
committed
refactor(schema): command logic removed from commitizen base
1 parent 1e9a827 commit 8425c7f

File tree

4 files changed

+6
-26
lines changed

4 files changed

+6
-26
lines changed

commitizen/commands/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from commitizen import factory
1+
from commitizen import factory, out
22

33

44
class Schema:
@@ -9,4 +9,4 @@ def __init__(self, config: dict, *args):
99
self.cz = factory.commiter_factory(self.config)
1010

1111
def __call__(self):
12-
self.cz.show_schema()
12+
out.write(self.cz.schema())

commitizen/cz/base.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from commitizen import out
21
from abc import ABCMeta, abstractmethod
32

43

@@ -7,14 +6,8 @@ def __init__(self, config: dict):
76
self.config = config
87

98
@abstractmethod
10-
def questions(self):
11-
"""Questions regarding the commit message.
12-
13-
Must have 'whaaaaat' format.
14-
More info: https://github.com/finklabs/whaaaaat/
15-
16-
:rtype: list
17-
"""
9+
def questions(self) -> list:
10+
"""Questions regarding the commit message."""
1811

1912
@abstractmethod
2013
def message(self, answers: dict) -> dict:
@@ -31,6 +24,3 @@ def schema(self) -> str:
3124
def info(self) -> str:
3225
"""Information about the standardized commit message."""
3326
raise NotImplementedError("Not Implemented yet")
34-
35-
def show_schema(self, *args, **kwargs):
36-
out.write(self.schema())

tests/test_commands.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ def test_info():
3636

3737

3838
def test_schema():
39-
with mock.patch("commitizen.factory.commiter_factory") as mocked_factory:
40-
mock_cz = mock.Mock()
41-
mocked_factory.return_value = mock_cz
39+
with mock.patch("commitizen.out.write") as write_mock:
4240
commands.Schema(config)()
43-
44-
mocked_factory.assert_called_once()
45-
mock_cz.show_schema.assert_called_once()
41+
write_mock.assert_called_once()
4642

4743

4844
def test_list_cz():

tests/test_cz_base.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,3 @@ def test_info():
4444
cz = DummyCz(config)
4545
with pytest.raises(NotImplementedError):
4646
cz.info()
47-
48-
49-
def test_show_schema():
50-
cz = DummyCz(config)
51-
with pytest.raises(NotImplementedError):
52-
cz.show_schema()

0 commit comments

Comments
 (0)