Пример #1
0
 def test_update(self):
     mock_recipe()
     buildout = {'buildout': {'directory': '/fake'}, 'instance': None}
     options = {'packages-under-test': 'package.*'}
     recipe = RoadrunnerPloneRecipe(buildout, 'roadrunner', options)
     recipe.install = self.mocker.mock()
     
     self.expect(recipe.install())
     self.mocker.replay()
     
     self.assertEquals(recipe.update(), None)
     unmock_recipe()
Пример #2
0
    def test_packages_under_test(self):
        # self.instance_part = buildout[options.get('zope2-instance', 'instance')]
        # self.part_dir = self.buildout['buildout']['directory'] + "/parts/" + self.name
        # self.packages_under_test = options.get('packages-under-test', '').split()
        
        mock_recipe()
        buildout = {'buildout': {'directory': '/fake'}, 'instance': None}
        options = {'packages-under-test': 'package.*'}
        recipe = RoadrunnerPloneRecipe(buildout, 'roadrunner', options)
        self.assertEquals(recipe.is_package_under_test('/fake/eggs/package.foo'), True)
        self.assertEquals(recipe.is_package_under_test('/fake/eggs/other.foo'), False)

        unmock_recipe()
Пример #3
0
    def test_with_packages_in_package_includes(self):
        buildout = dict(
            buildout={
                'eggs-directory': '',
                'directory': '/fake',
            },
            instance = {
                'location': '/fake/parts/instance',
                'eggs': 'egg1\negg2',
                'zope2-location': '/zope2/location',
            },
        )
        options = {
            'eggs': 'egg1\negg2'
        }

        #mock out the files returned from os.walk in ../etc/package-includes
        os.walk = self.mocker.mock()
        self.expect(os.walk('/fake/parts/roadrunner/etc/package-includes')).result([('dir','2',['filename1'])])
        RoadrunnerPloneRecipe.is_package_under_test = self.mocker.mock()
        self.expect(RoadrunnerPloneRecipe.is_package_under_test('filename1')).result(True)
        os.remove = self.mocker.mock()
        self.expect(os.remove('dir/filename1'))

        # mock out file reading
        orig_file = __builtins__['file']
        f = self.mocker.mock()
        __builtins__['file'] = f
        my_file = self.mocker.mock()
        my_file.read()
        self.mocker.result('/fake/parts/instance')
        self.expect(f('/fake/parts/roadrunner/etc/zope.conf'))
        self.mocker.result(my_file)

        # mock out file reading
        write_file = self.mocker.mock()
        write_file.write('/fake/parts/roadrunner')
        f('/fake/parts/roadrunner/etc/zope.conf', 'w')
        self.mocker.result(write_file)
        ct = self.mocker.replace('shutil.copytree')
        ct(buildout['instance']['location'], '/fake/parts/roadrunner')
        self.mocker.result(True)

        mock_recipe()
        self.mocker.replay()

        recipe = RoadrunnerPloneRecipe(buildout, 'roadrunner', options)
        self.assertEquals(recipe.install(), ['/fake/parts/roadrunner'])
        unmock_recipe()
Пример #4
0
    def test_recipe_with_os_path_exists(self):
        buildout = dict(
            buildout={
                'eggs-directory': '',
                'directory': '/fake',
            },
            instance = {
                'location': '/fake/parts/instance',
                'eggs': 'egg1\negg2',
                'zope2-location': '/zope2/location',
            },
        )
        options = {
            'eggs': 'egg1\negg2'
        }
        
        # mock out parts directory existing and shutil call after it.
        # not important since the algorithm is just delete the directory if it exists
        os.path.exists = self.mocker.replace('os.path.exists')
        os.path.exists('/fake/parts/roadrunner')
        self.mocker.result(True)
        shutil.rmtree = self.mocker.mock()
        self.expect(shutil.rmtree('/fake/parts/roadrunner'))

        # mock out file reading
        orig_file = __builtins__['file']
        f = self.mocker.mock()
        __builtins__['file'] = f
        my_file = self.mocker.mock()
        my_file.read()
        self.mocker.result('/fake/parts/instance')
        self.expect(f('/fake/parts/roadrunner/etc/zope.conf'))
        self.mocker.result(my_file)

        # mock out file reading
        write_file = self.mocker.mock()
        write_file.write('/fake/parts/roadrunner')
        f('/fake/parts/roadrunner/etc/zope.conf', 'w')
        self.mocker.result(write_file)
        ct = self.mocker.replace('shutil.copytree')
        ct(buildout['instance']['location'], '/fake/parts/roadrunner')
        self.mocker.result(True)

        mock_recipe()
        self.mocker.replay()

        recipe = RoadrunnerPloneRecipe(buildout, 'roadrunner', options)
        self.assertEquals(recipe.install(), ['/fake/parts/roadrunner'])
        unmock_recipe()
Пример #5
0
 def test_basic_recipe(self):
     buildout = dict(
         buildout={
             'eggs-directory': '',
             'directory': '/fake',
         },
         instance = {
             'location': '/fake/parts/instance',
             'eggs': 'egg1\negg2',
             'zope2-location': '/zope2/location',
         },
     )
     options = {
         'eggs': 'egg1\negg2'
     }
     # self.mocker.replace('os.path.exists')().result(True)
     # self.mocker.replace('os.mkdir')().result(True)
     
     # mock out file reading
     orig_file = __builtins__['file']
     f = self.mocker.mock()
     __builtins__['file'] = f
     my_file = self.mocker.mock()
     my_file.read()
     self.mocker.result('/fake/parts/instance')
     self.expect(f('/fake/parts/roadrunner/etc/zope.conf'))
     self.mocker.result(my_file)
     
     # mock out file reading
     write_file = self.mocker.mock()
     write_file.write('/fake/parts/roadrunner')
     f('/fake/parts/roadrunner/etc/zope.conf', 'w')
     self.mocker.result(write_file)
     ct = self.mocker.replace('shutil.copytree')
     ct(buildout['instance']['location'], '/fake/parts/roadrunner')
     self.mocker.result(True)
     
     mock_recipe()
     self.mocker.replay()
     
     recipe = RoadrunnerPloneRecipe(buildout, 'roadrunner', options)
     self.assertEquals(recipe.install(), ['/fake/parts/roadrunner'])
     unmock_recipe()