def test_test4(self): """ Generation of files: creationg """ if hasattr(self, "assertLogs"): django_yamlconf.add_attributes( self.settings, { 'USE_A': True, 'A': 'a', 'YAMLCONF_SYSFILES_DIR': os.path.join(self.sysfiles_root, "test4"), }, "**TESTING**") with self.assertLogs('', level='DEBUG') as logs: rootdir = os.path.join(TestYCSysfiles.BASE_DIR, "root") django_yamlconf.sysfiles( create=True, noop=False, settings=self.settings, rootdir=rootdir, render=self.render, ) self.assertRegex( " ".join(logs.output), 'Updating the system control file ' + '".*root.etc.xmpl.txt"', )
def handle(self, *args, **options): """ Implmentation of the command, simply walk the templates "sys" directory and use "render_to_string" using the YAMLCONF attributes to create the contents for the system control file. """ super(Command, self).handle(*args, **options) sysfiles(options['create'], options['noop'], settings, options['root'])
def test_test6(self): """ Missing sys files directory """ if hasattr(self, "assertLogs"): django_yamlconf.add_attributes(self.settings, { 'A': 'a', }, "**TESTING**") with self.assertLogs('', level='DEBUG') as logs: django_yamlconf.sysfiles( create=False, noop=True, settings=self.settings, render=self.render, ) self.assertIn('No YAMLCONF_SYSFILES_DIR settings defined', "\n".join(logs.output))
def test_test1(self): """ Simple reference to an attribute """ if hasattr(self, "assertLogs"): django_yamlconf.add_attributes( self.settings, { 'A': 'a', 'YAMLCONF_SYSFILES_DIR': os.path.join(self.sysfiles_root, "test1"), }, "**TESTING**") with self.assertLogs('', level='DEBUG') as logs: django_yamlconf.sysfiles( create=False, noop=True, settings=self.settings, render=self.render, ) self.assertIn('Value of A is a.', "\n".join(logs.output))
def test_test3(self): """ Generation of files: non-writeable """ if hasattr(self, "assertLogs"): django_yamlconf.add_attributes( self.settings, { 'A': True, 'YAMLCONF_SYSFILES_DIR': os.path.join(self.sysfiles_root, "test3"), }, "**TESTING**") with self.assertLogs('', level='DEBUG') as logs: django_yamlconf.sysfiles( create=True, noop=False, settings=self.settings, render=self.render, ) self.assertIn( 'Skipping non-writeable or missing system file: ' + '"/myapp/tmpl.txt"', "\n".join(logs.output))
def test_test2(self): """ Reference to a dictionary based attribute """ if hasattr(self, "assertLogs"): self.settings.DATABASES = {} django_yamlconf.add_attributes( self.settings, { 'DATABASES.default.PASSWORD': '******', 'YAMLCONF_SYSFILES_DIR': os.path.join(self.sysfiles_root, "test2"), }, "**TESTING**") with self.assertLogs('', level='DEBUG') as logs: django_yamlconf.sysfiles( create=False, noop=True, settings=self.settings, render=self.render, ) self.assertIn('DB password is is Welcome.', "\n".join(logs.output))