def _generate_urls_conf(): global projectname _print_verbose(2, 'Configuring project URLs ...') gen_by_comment = '# generated by django Organice' project = DjangoModuleManager(projectname) project.add_file('urls', lines=(gen_by_comment, 'from organice.urls import urlpatterns # noqa')) project.save_files()
def test_read_module(): """Read a submodule (file) in an existing module.""" module = DjangoModuleManager('test_project_settings', 'kitchen') module.add_file('cook') thefile = module.get_file('cook') content = module.get_data('cook') pathname = os.path.join('test_project_settings', 'kitchen', 'cook.py') thefile.seek(0) assert thefile.read() == content assert len( content ) > 40, "Submodule file is too short! Something's wrong. '%s'" % content assert thefile.name == pathname
def test_create_module(): """Create a module, and create a submodule (file) in it.""" module_content = [ '# this is a test module', 'KITCHEN = "Veggie Surprises"', 'CARROTS = 50', ] module = DjangoModuleManager('test_project_settings', 'kitchen') module.add_file('cook', lines=module_content) module.save_files() thefile = module.get_file('cook') thefile.seek(0) file_content = thefile.read() assert file_content.startswith(module_content[0])