Add a test for the createsettings command.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-08-29 21:51:51 -04:00
parent 1d5e793c84
commit e0d8a1d7b3

View File

@@ -0,0 +1,32 @@
from __future__ import unicode_literals
import os
import uuid
from django.core import management
from django.conf import settings
from django.utils.encoding import force_text
from ..utils import fs_cleanup
from ..management.commands.literals import SETTING_FILE_TEMPLATE
from .base import BaseTestCase
class CommonCommandsTestCase(BaseTestCase):
def test_createsettings_command(self):
filename = force_text(uuid.uuid4())
with self.settings(COMMON_LOCAL_SETTINGS_FILENAME=filename):
management.call_command('createsettings', interactive=False)
file_path = os.path.join(
settings.BASE_DIR, 'settings', '{}.py'.format(filename)
)
with open(file_path) as file_object:
content = file_object.read()
fs_cleanup(filename=file_path)
# Compare without the string substitution and the final linefeeds
self.assertTrue(
SETTING_FILE_TEMPLATE.replace("{0}'", '')[0:-2] in content
)