UPD: try to make useful test stuff.

This commit is contained in:
2019-03-15 17:35:16 +01:00
parent 2dce52cb25
commit 1c3e5bf761
6 changed files with 130 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import os
import pkg_resources
import posix
import sys
from django.core.management import execute_from_command_line
from dav_base.config.modules import DJANGO_MAIN_MODULE, ModuleConfig
@@ -27,6 +28,25 @@ class AdminCommand(object):
subparser.add_argument('path', metavar='PATH',
help='A directory, where the project files will be installed.')
subparser = subparsers.add_parser('enable_module',
help='Enable a modular app within your django-dav installation.')
subparser.add_argument('path', metavar='PATH',
help='The directory, where your django project files are installed.')
subparser.add_argument('module', metavar='MODULE',
help='The name of the module.')
subparser = subparsers.add_parser('disable_module',
help='Disable a modular app within your django-dav installation.')
subparser.add_argument('path', metavar='PATH',
help='The directory, where your django project files are installed.')
subparser.add_argument('module', metavar='MODULE',
help='The name of the module.')
subparser = subparsers.add_parser('list_modules',
help='List enabled modular apps within your django-dav installation.')
subparser.add_argument('path', metavar='PATH',
help='The directory, where your django project files are installed.')
return parser
def _parse_args(self, argv=None):
@@ -91,6 +111,32 @@ class AdminCommand(object):
return posix.EX_OK
def _subcmd_enable_module(self, cmd_args):
django_main_module = DJANGO_MAIN_MODULE
django_base_dir = cmd_args.path
module_name = cmd_args.module
sys.path.append(django_base_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = '{}.settings'.format(django_main_module)
execute_from_command_line(['manage.py', 'enable_module', module_name])
return posix.EX_OK
def _subcmd_disable_module(self, cmd_args):
django_main_module = DJANGO_MAIN_MODULE
django_base_dir = cmd_args.path
module_name = cmd_args.module
sys.path.append(django_base_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = '{}.settings'.format(django_main_module)
execute_from_command_line(['manage.py', 'disable_module', module_name])
return posix.EX_OK
def _subcmd_list_modules(self, cmd_args):
django_main_module = DJANGO_MAIN_MODULE
django_base_dir = cmd_args.path
sys.path.append(django_base_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = '{}.settings'.format(django_main_module)
execute_from_command_line(['manage.py', 'list_modules'])
return posix.EX_OK
def __init__(self):
self._argparser = self._setup_argparser()