def test_parse_complicated_buildout(self):
        fp = mktmpcfg(complicated_buildout_cfg)
        buildout_object = buildout_parse(fp.name)

        assert buildout_object['buildout'].keys() == ['parts', 'unzip']

        assert buildout_object['buildout']['parts'] == ['eggs', 'django', 'pyzmq']
Example #2
0
    def test_parse_replacements(self):
        fp = mktmpcfg(complicated_buildout_cfg)
        bc = buildout_parse(fp.name)

        eggrecipe = recipes['zc.recipe.egg']
        eg = eggrecipe(bc, 'eggs')

        assert eg.extra_paths == ['${buildout:directory}/parts/django',
            '${buildout:directory}/parts/django-registration',
            '${buildout:directory}/greatbigcrane',
            '${buildout:directory}/parts/pyzmq',
            ]

        eg.extra_paths = '/something/${buildout:directory}/another/thing'

        djangorecipe = recipes['djangorecipe']
        dr = djangorecipe(bc, 'django')

        assert dr.eggs == '${eggs:eggs}'

        fp.seek(0)
        buildout_write(fp.name, bc)

        data = fp.read()
        assert data == """[buildout]
Example #3
0
    def test_parse_djangorecipe(self):
        fp = mktmpcfg(complicated_buildout_cfg)
        bc = buildout_parse(fp.name)

        djangorecipe = recipes['djangorecipe']
        dr = djangorecipe(bc, 'django')

        assert dr.settings == 'development'
        assert dr.version == '1.2.1'
        assert dr.extra_paths == '${eggs:extra-paths}'
        assert dr.fcgi == True
Example #4
0
    def test_change_existing_djangorecipe(self):
        fp = mktmpcfg(complicated_buildout_cfg)
        bc = buildout_parse(fp.name)

        djangorecipe = recipes['djangorecipe']
        dr = djangorecipe(bc, 'django')

        dr.settings = 'production'
        dr.version = '1.1.1'
        dr.fcgi = False
        dr.wsgi = False
        dr.eggs = [dr.eggs, '${pyzmq:parts}']

        fp.seek(0)
        buildout_write(fp.name, bc)
        
        data = fp.read()
        assert data == """[buildout]
Example #5
0
 def buildout(self):
     sections = buildout_parse(self.buildout_filename())
     return sections
    def test_parse_simplest_buildout(self):
        fp = mktmpcfg(simple_buildout_cfg)
        buildout_object = buildout_parse(fp.name)

        assert buildout_object['buildout']['parts'] == []
Example #7
0
def test_buildout(project_id):
    """Run the test command in the buildout project's base directory.
    Tries to do some intelligent guessing about how tests should be run."""
    project = Project.objects.get(id=project_id)
    print("running tests for %s" % project.name)

    test_binaries = []

    # FIXME: HOLY NESTED CONDITIONALS, BATMAN
    # figure out what test commands to run
    if project.project_type == "buildout":
        bc = buildout_parse(project.buildout_filename())

        parts = bc['buildout']['parts']
        if not isinstance(parts, list):
            parts = [parts]

        # We get to do some detection in this one
        # First look for django test
        for section, values in bc.iteritems():
            if section in parts:
                if values.get('recipe') == 'djangorecipe':
                    # Django, we know what's going on
                    if 'test' in values:
                        test_script = 'test'
                        if 'testrunner' in values:
                            test_script = values['testrunner']
                        test_binaries.append('bin/' + test_script)
                    else:
                        test_script = section
                        if 'control-script' in values:
                            test_script = values['control-script']
                        test_binaries.append('bin/' + test_script + ' test')
                elif values.get('recipe') == 'zc.recipe.testrunner':
                    test_script = section
                    if 'script' in values:
                        test_script = values['control-script']
                    test_binaries.append('bin/' + test_script)
    elif project.project_type == "pip":
        # FIXME: Do you use windows and this command failed? Patches welcome.
        command = "source %s ; %s" % (
                os.path.join(project.pipproject.virtualenv_path, 'bin',
                    'activate'),
                project.pipproject.test_command)
        test_binaries.append(command)

    # Run the test commands
    errors = False
    responses = []
    try:
        Notification.objects.create(status="general",
                summary="Testing of '%s' started" % (project.name),
                message="Testing for '%s' project has started" % (project.name),
                project=project)
        for binary in test_binaries:
            process = subprocess.Popen(binary, cwd=project.base_directory,
                    stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)

            responses.append(process.communicate()[0])
            errors = errors or process.returncode != 0

        # Make the output a little nicer when you run multiple test suites

        message = []
        for test_command, response in zip(test_binaries, responses):
            com_length = len(test_command)+1
            response_set = []
            response_set.append('='*com_length)
            response_set.append('\n')
            response_set.append(test_command)
            response_set.append(':')
            response_set.append('\n')
            response_set.append('='*com_length)
            response_set.append('\n')
            response_set.append(response)
            message.append(''.join(response_set))
    except Exception:
        project.test_status = False
        project.save
        raise

    Notification.objects.create(status="success" if not errors else "error",
            summary="Testing '%s' %s" % (
                project.name, "success" if not errors else "error"),
            message=('\n\n'+'*'*50+'\n\n').join(message),
            project=project,
            notification_type="TEST",
            )
    project.test_status = not errors
    project.save()