Ejemplo n.º 1
0
    def test_verbose(self):
        self._run_cheesecake('--path %s' % PACKAGE_PATH)
        normal = read_file_contents(self.stdout_name)
        self._cleanup()

        self._run_cheesecake('--path %s --verbose' % PACKAGE_PATH)
        verbose = read_file_contents(self.stdout_name)

        # Make sure that --verbose generates more information than default operation.
        assert len(verbose) > len(normal)
Ejemplo n.º 2
0
    def test_quiet(self):
        self._run_cheesecake('--path %s' % PACKAGE_PATH)
        normal = read_file_contents(self.stdout_name)
        self._cleanup()

        self._run_cheesecake('--path %s --quiet' % PACKAGE_PATH)
        quiet = read_file_contents(self.stdout_name)

        # Make sure that --quiet generates less information than default operation.
        assert len(quiet) < len(normal)
Ejemplo n.º 3
0
    def test_sum(self):
        installability_regex = r'INSTALLABILITY INDEX \(RELATIVE\) \.\.\.\.\.\.\.\.\s+(\d+)\s+\((\d+) out of a maximum of (\d+) points is (\d+)%\)'
        documentation_regex = r'DOCUMENTATION INDEX \(RELATIVE\) \.\.\.\.\.\.\.\.\.\s+(\d+)\s+\((\d+) out of a maximum of (\d+) points is (\d+)%\)'
        code_kwalitee_regex = r'CODE KWALITEE INDEX \(RELATIVE\) \.\.\.\.\.\.\.\.\.\s+(-*\d+)\s+\((-*\d+) out of a maximum of (\d+) points is (-*\d+)%\)'

        self._run_cheesecake('-p %s' % os.path.join(DATA_PATH, 'required.tar.gz'))

        self._assert_success()

        # Check that scores are added up and scaled properly.
        stdout = read_file_contents(self.stdout_name)

        installability_match = re.search(installability_regex, stdout)
        documentation_match = re.search(documentation_regex, stdout)
        code_kwalitee_match = re.search(code_kwalitee_regex, stdout)

        assert installability_match
        assert documentation_match
        assert code_kwalitee_match

        overall_score = 0
        overall_maximum = 0
        for index in [installability_match, documentation_match, code_kwalitee_match]:
            percent_one, current, maximum, percent_two = index.groups()
            assert percent_one == percent_two
            overall_score += int(current)
            overall_maximum += int(maximum)
            print "Score: %d/%d" % (int(current), int(maximum))

        overall_percent = ceil(overall_score / float(overall_maximum))

        print "Computed overall score: %d" % overall_score
        assert 'OVERALL CHEESECAKE INDEX (ABSOLUTE) .... %3d' % overall_score in stdout
        assert 'OVERALL CHEESECAKE INDEX (RELATIVE) .... %3d  (%d out of a maximum of %d points is %d%%)' % \
               (overall_percent, overall_score, overall_maximum, overall_percent)
Ejemplo n.º 4
0
    def test_help(self):
        self._run_cheesecake('--help')

        self._assert_success()

        # Make sure usage information has been shown.
        stdout = read_file_contents(self.stdout_name)
        assert 'usage:' in stdout
Ejemplo n.º 5
0
    def test_no_args(self):
        self._run_cheesecake('')

        assert self.return_code != 0

        # Make sure that there's a reference to --help.
        stdout = read_file_contents(self.stdout_name)
        assert '--help' in stdout
Ejemplo n.º 6
0
    def test_path(self):
        self._run_cheesecake('--path %s' % NOSE_PATH)

        self._assert_success()

        # Make sure that appropriate indices have been counted.
        stdout = read_file_contents(self.stdout_name)
        assert pad_msg('unpack', IndexUnpack.max_value) in stdout
        assert pad_msg('unpack_dir', IndexUnpackDir.max_value) in stdout
        assert pad_msg('install', IndexInstall.max_value) in stdout
Ejemplo n.º 7
0
    def test_url(self):
        self._run_cheesecake('--url http://www.agilistas.org/cheesecake/nose-0.8.3.tar.gz')

        self._assert_success()

        # Make sure that appropriate indices have been counted.
        stdout = read_file_contents(self.stdout_name)
        assert pad_msg('unpack', IndexUnpack.max_value) in stdout
        assert pad_msg('unpack_dir', IndexUnpackDir.max_value) in stdout
        assert pad_msg('install', IndexInstall.max_value) in stdout
        assert pad_msg('url_download', IndexUrlDownload.max_value) in stdout
Ejemplo n.º 8
0
    def test_name(self):
        self._run_cheesecake('--name nose')

        self._assert_success()

        # Make sure that appropriate indices have been counted.
        stdout = read_file_contents(self.stdout_name)
        assert pad_msg('unpack', IndexUnpack.max_value) in stdout
        assert pad_msg('install', IndexInstall.max_value) in stdout
        # PyPI score can be lowered by penalties, so we don't include score check here.
        assert 'py_pi_download' in stdout
Ejemplo n.º 9
0
    def test_required_files(self):
        self._run_cheesecake('-p %s' % os.path.join(DATA_PATH, 'required.tar.gz'))

        self._assert_success()

        stdout = read_file_contents(self.stdout_name)
        # Files in package: INSTALL, Install.html, README and TODO.
        assert '(2 files and 0 required directories found)' in stdout
        # One not documented module with a single function with a docstring.
        assert '(found 1/2=50.00% objects with docstrings)' in stdout
        assert pad_msg('docstrings', 50) in stdout
        assert '(found 0/2=0.00% objects with formatted docstrings)' in stdout