Make thinks more useful
Some checks failed
buildbot/tox Build done.

Extract functionality from program.Program to api, so it can be used
from other python code.
And instead of adding predefined urls to root_urlconf, we should
/mount/ apps into a django project.
This commit is contained in:
2019-11-15 17:07:10 +01:00
parent a84c473866
commit 18613d3600
5 changed files with 98 additions and 22 deletions

View File

@@ -0,0 +1,27 @@
import os
import unittest
import pytest
from ..api import DjangoProject
from ..config import DJANGO_SETTINGS_DIR
class DjangoProjectTestCase(unittest.TestCase):
@pytest.fixture(autouse=True)
def tmpdir(self, tmpdir): # pylint: disable=method-hidden
self.tmpdir = tmpdir
def _assert_django_project(self, project_dir):
self.assertTrue(os.path.isdir(project_dir), 'no directory: {}'.format(project_dir))
settings_dir = os.path.join(project_dir, DJANGO_SETTINGS_DIR)
self.assertTrue(os.path.isdir(settings_dir), 'no directory: {}'.format(settings_dir))
settings_file = os.path.join(settings_dir, 'settings.py')
self.assertTrue(os.path.isfile(settings_file), 'no file: {}'.format(settings_file))
manage_script = os.path.join(project_dir, 'manage.py')
self.assertTrue(os.path.isfile(manage_script), 'no file: {}'.format(manage_script))
def test_create(self):
project_dir = os.path.join(str(self.tmpdir), 'django')
project = DjangoProject(project_dir)
project.create()
self._assert_django_project(project_dir)