-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added print vrsion management command
- Loading branch information
Showing
9 changed files
with
132 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# django-project-version | ||
# djversion/management/__init__.py | ||
|
||
|
||
from typing import List # pylint: disable=W0611 | ||
|
||
|
||
__all__ = [] # type: List[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# django-project-version | ||
# djversion/management/commands/__init__.py | ||
|
||
|
||
from typing import List # pylint: disable=W0611 | ||
|
||
|
||
__all__ = [] # type: List[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# django-project-version | ||
# djversion/management/commands/print-version.py | ||
|
||
|
||
import sys | ||
from typing import Any, Dict, List # pylint: disable=W0611 | ||
|
||
from django.core.management.base import BaseCommand | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from djversion.utils import get_version | ||
|
||
|
||
__all__ = ["Command"] # type: List[str] | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Version management command. | ||
""" | ||
|
||
help = str(_("Print project version")) | ||
|
||
def handle(self, *args: List[Any], **kwargs: Dict[str, Any]) -> None: | ||
""" | ||
Perform command. | ||
:param args: additional args. | ||
:type args: List[Any]. | ||
:param kwargs: additional args. | ||
:type kwargs: Dict[str, Any]. | ||
:return: nothing. | ||
:rtype: None. | ||
""" | ||
|
||
version = get_version() | ||
|
||
sys.stdout.write(f"{version}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# django-project-version | ||
# tests/management/__init__.py | ||
|
||
|
||
from typing import List # pylint: disable=W0611 | ||
|
||
|
||
__all__ = [] # type: List[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# django-project-version | ||
# tests/management/commands/__init__.py | ||
|
||
|
||
from typing import List # pylint: disable=W0611 | ||
|
||
|
||
__all__ = [] # type: List[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# django-project-version | ||
# tests/management/commands/test_print-version.py | ||
import contextlib | ||
from io import StringIO | ||
from typing import List # pylint: disable=W0611 | ||
|
||
from django.core.management import call_command | ||
from django.test import TestCase | ||
|
||
|
||
__all__ = ["PrintVersionManagementCommandTest"] # type: List[str] | ||
|
||
|
||
class PrintVersionManagementCommandTest(TestCase): | ||
""" | ||
Print version management command tests. | ||
""" | ||
|
||
def test_handle(self) -> None: | ||
""" | ||
Must return version to stdout. | ||
:return: nothing. | ||
:rtype: None. | ||
""" | ||
|
||
out = StringIO() | ||
|
||
with contextlib.redirect_stdout(out): | ||
call_command("print-version") | ||
|
||
result = out.getvalue().strip() | ||
|
||
self.assertEqual(first=result, second="1.0.1 (Aug. 24, 1991)") |