示例#1
0
    def setUp(self):
        # Create a directory for our buildout files created by the recipe
        self.buildout_dir = tempfile.mkdtemp('djangorecipe')

        self.bin_dir = os.path.join(self.buildout_dir, 'bin')
        self.develop_eggs_dir = os.path.join(self.buildout_dir, 'develop-eggs')
        self.eggs_dir = os.path.join(self.buildout_dir, 'eggs')
        self.parts_dir = os.path.join(self.buildout_dir, 'parts')

        # We need to create the bin dir since the recipe should be able to
        # expect it exists
        os.mkdir(self.bin_dir)

        self.recipe_initialisation = [{
            'buildout': {
                'eggs-directory': self.eggs_dir,
                'develop-eggs-directory': self.develop_eggs_dir,
                'bin-directory': self.bin_dir,
                'parts-directory': self.parts_dir,
                'directory': self.buildout_dir,
                'python': 'buildout',
                'executable': sys.executable,
                'find-links': '',
                'allow-hosts': ''
            },
        }, 'django', {
            'recipe': 'djangorecipe'
        }]

        self.recipe = Recipe(*self.recipe_initialisation)
示例#2
0
    def test_relative_paths_true(self):
        recipe = Recipe({
                'buildout': {
                    'eggs-directory': self.eggs_dir,
                    'develop-eggs-directory': self.develop_eggs_dir,
                    'python': 'python-version',
                    'bin-directory': self.bin_dir,
                    'parts-directory': self.parts_dir,
                    'directory': self.buildout_dir,
                    'find-links': '',
                    'allow-hosts': '',
                    'develop': '.',
                    'relative-paths': 'true'
                    },
                'python-version': {'executable': sys.executable}},
                             'django',
                             {'recipe': 'djangorecipe',
                              'wsgi': 'true'})
        recipe.make_scripts([], [])
        recipe.create_manage_script([], [])

        manage = os.path.join(self.bin_dir, 'django')
        wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')

        expected = base = 'base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))'
        self.assertTrue(expected in open(manage).read())
        self.assertTrue(expected in open(wsgi_script).read())
示例#3
0
文件: tests.py 项目: abingham/youblob
    def test_boilerplate_1_2(self):
        """Test the boilerplate for django 1.2."""

        recipe = Recipe({
                'buildout': {'eggs-directory': self.eggs_dir,
                             'develop-eggs-directory': self.develop_eggs_dir,
                             'python': 'python-version',
                             'bin-directory': self.bin_dir,
                             'parts-directory': self.parts_dir,
                             'directory': self.buildout_dir,
                             'find-links': '',
                             'allow-hosts': '',
                             'versions': 'versions',
                             },
                'versions': {'django': '1.2.5'},
                'python-version': {'executable': '/python4k'},
                'py5k': {'executable': '/python5k'}},
                        'django',
                        {'recipe': 'djangorecipe',
                         'python': 'py5k', 'wsgi': 'true'})

        secret = '$55upfci7a#gi@&e9o1-hb*k+f$3+(&b$j=cn67h#22*0%-bj0'
        recipe.generate_secret = lambda: secret

        project_dir = os.path.join(self.buildout_dir, 'project')
        recipe.create_project(project_dir)
        settings = open(os.path.join(project_dir, 'settings.py')).read()
        settings_dict = {'project': self.recipe.options['project'],
                         'secret': secret,
                         'urlconf': self.recipe.options['urlconf'],
                         }
        from djangorecipe.boilerplate import versions
        self.assertEquals(versions['1.2']['settings'] % settings_dict,
                          settings)
示例#4
0
 def test_consistent_options(self):
     # Buildout is pretty clever in detecting changing options. If
     # the recipe modifies it's options during initialisation it
     # will store this to determine wheter it needs to update or do
     # a uninstall & install. We need to make sure that we normally
     # do not trigger this. That means running the recipe with the
     # same options should give us the same results.
     self.assertEqual(*[
         Recipe(
             {
                 'buildout': {
                     'eggs-directory': self.eggs_dir,
                     'develop-eggs-directory': self.develop_eggs_dir,
                     'python': 'python-version',
                     'bin-directory': self.bin_dir,
                     'parts-directory': self.parts_dir,
                     'directory': self.buildout_dir,
                     'find-links': '',
                     'allow-hosts': '',
                 },
                 'python-version': {
                     'executable': sys.executable
                 }
             }, 'django', {
                 'recipe': 'djangorecipe'
             }).options.copy() for i in range(2)
     ])
示例#5
0
文件: tests.py 项目: abingham/youblob
 def test_python_option(self):
     # The python option makes it possible to specify a specific Python
     # executable which is to be used for the generated scripts.
     recipe = Recipe({
             'buildout': {
                 'eggs-directory': self.eggs_dir,
                 'develop-eggs-directory': self.develop_eggs_dir,
                 'python': 'python-version',
                 'bin-directory': self.bin_dir,
                 'parts-directory': self.parts_dir,
                 'directory': self.buildout_dir,
                 'find-links': '',
                 'allow-hosts': '',
                 },
             'python-version': {'executable': '/python4k'}},
                     'django',
                     {'recipe': 'djangorecipe',
                      'wsgi': 'true'})
     recipe.make_scripts([], [])
     # This should have created a script in the bin dir
     wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')
     self.assertEqual(open(wsgi_script).readlines()[0], '#!/python4k\n')
     # Changeing the option for only the part will change the used Python
     # version.
     recipe = Recipe({
             'buildout': {'eggs-directory': self.eggs_dir,
                          'develop-eggs-directory': self.develop_eggs_dir,
                          'python': 'python-version',
                          'bin-directory': self.bin_dir,
                          'parts-directory': self.parts_dir,
                          'directory': self.buildout_dir,
                          'find-links': '',
                          'allow-hosts': '',
                          },
             'python-version': {'executable': '/python4k'},
             'py5k': {'executable': '/python5k'}},
                     'django',
                     {'recipe': 'djangorecipe',
                      'python': 'py5k', 'wsgi': 'true'})
     recipe.make_scripts([], [])
     self.assertEqual(open(wsgi_script).readlines()[0], '#!/python5k\n')
示例#6
0
    def test_boilerplate_1_2(self):
        """Test the boilerplate for django 1.2."""

        recipe_args = copy.deepcopy(self.recipe_initialisation)

        recipe_args[0]['versions'] = {'django': '1.2.5'}
        recipe = Recipe(*recipe_args)

        secret = '$55upfci7a#gi@&e9o1-hb*k+f$3+(&b$j=cn67h#22*0%-bj0'
        recipe.generate_secret = lambda: secret

        project_dir = os.path.join(self.buildout_dir, 'project')
        recipe.create_project(project_dir)
        settings = open(os.path.join(project_dir, 'settings.py')).read()
        settings_dict = {'project': self.recipe.options['project'],
                         'secret': secret,
                         'urlconf': self.recipe.options['urlconf'],
                         }
        from djangorecipe.boilerplate import versions

        self.assertEqual(versions['1.2']['settings'] % settings_dict,
                          settings)