Example #1
0
    def test_known_licenses(self):
        """Test the KNOWN_LICENSES"""

        total_licenses = len(KNOWN_LICENSES)
        self.assertEqual(total_licenses,
                         3,
                         msg='shared_setup has %s licenses' % total_licenses)

        md5sums = []
        for short, data in KNOWN_LICENSES.items():
            # the known text must be in known_licenses dir with the short name
            fn = os.path.join(self.setup.REPO_BASE_DIR, 'known_licenses',
                              short)
            self.assertTrue(os.path.isfile(fn),
                            msg='license %s is in known_licenses directory' %
                            short)

            md5sum = self.setup.get_md5sum(fn)
            self.assertEqual(
                data[0],
                md5sum,
                msg=
                'md5sum from KNOWN_LICENSES %s matches the one in known_licenses dir %s for %s'
                % (data[0], md5sum, short))
            self.assertFalse(md5sum in md5sums,
                             msg='md5sum for license %s is unique' % md5sum)

            lic_name, classifier = self.setup.get_license(license_name=fn)
            self.assertEqual(lic_name,
                             os.path.basename(fn),
                             msg='file %s is license %s' % (fn, lic_name))
            self.assertTrue(
                classifier.startswith('License :: OSI Approved :: ')
                or classifier == 'License :: Other/Proprietary License',
                msg='classifier as expected for %s' % short)
Example #2
0
    def test_known_licenses(self):
        """Test the KNOWN_LICENSES"""

        total_licenses = len(KNOWN_LICENSES)
        self.assertEqual(total_licenses, 3,
                         msg='shared_setup has %s licenses' % total_licenses)

        md5sums = []
        for short, data in KNOWN_LICENSES.items():
            # the known text must be in known_licenses dir with the short name
            fn = os.path.join(self.setup.REPO_BASE_DIR, 'known_licenses', short)
            self.assertTrue(os.path.isfile(fn),
                            msg='license %s is in known_licenses directory' % short)

            md5sum = self.setup.get_md5sum(fn)
            self.assertEqual(data[0], md5sum,
                             msg='md5sum from KNOWN_LICENSES %s matches the one in known_licenses dir %s for %s' %
                             (data[0], md5sum, short))
            self.assertFalse(md5sum in md5sums,
                             msg='md5sum for license %s is unique' % md5sum)

            lic_name, classifier = self.setup.get_license(license_name=fn)
            self.assertEqual(lic_name, os.path.basename(fn),
                             msg='file %s is license %s' % (fn, lic_name))
            self.assertTrue(classifier.startswith('License :: OSI Approved :: ') or
                            classifier == 'License :: Other/Proprietary License',
                            msg='classifier as expected for %s' % short)
Example #3
0
    def test_release_on_pypi(self):
        """Release on pypi or not"""

        self.assertEqual(PYPI_LICENSES, ['LGPLv2+', 'GPLv2'], 'Expected licenses that allow releasing on pypi')

        for short in KNOWN_LICENSES.keys():
            self.assertEqual(self.setup.release_on_pypi(short), short in PYPI_LICENSES,
                             msg='can %s be usd to release on pypi' % short)
Example #4
0
    def test_release_on_pypi(self):
        """Release on pypi or not"""

        self.assertEqual(PYPI_LICENSES, ['LGPLv2+', 'GPLv2'], 'Expected licenses that allow releasing on pypi')

        for short in KNOWN_LICENSES.keys():
            self.assertEqual(release_on_pypi(short), short in PYPI_LICENSES,
                             msg='can %s be usd to release on pypi' % short)
Example #5
0
    def test_gen_license_header(self):
        """Test the generation of headers for all supported/known licenses"""

        data = {
            'name': 'projectname',
            'beginyear': 1234,
            'endyear': 5678,
            'url': 'https://example.com/projectname',
        }
        for license in KNOWN_LICENSES.keys():
            res_fn = os.path.join(self.setup.REPO_TEST_DIR, 'headers', license)
            result = open(res_fn).read()

            gen_txt = gen_license_header(license, **data)
            self.assertEqual(gen_txt, result, msg='generated header for license %s as expected' % license)
            log.info('generated license header %s' % license)
Example #6
0
    def test_gen_license_header(self):
        """Test the generation of headers for all supported/known licenses"""

        data = {
            'name': 'projectname',
            'beginyear': 1234,
            'endyear': 5678,
            'url': 'https://example.com/projectname',
        }
        for license in KNOWN_LICENSES.keys():
            res_fn = os.path.join(self.setup.REPO_TEST_DIR, 'headers', license)
            result = open(res_fn).read()

            gen_txt = gen_license_header(license, **data)
            self.assertEqual(gen_txt, result, msg='generated header for license %s as expected' % license)
            log.info('generated license header %s' % license)
Example #7
0
    def test_gen_license_header(self):
        """Test the generation of headers for all supported/known licenses"""

        data = {
            'name': 'projectname',
            'beginyear': 1234,
            'endyear': 5678,
            'url': 'https://github.com/hpcugent/projectname',
        }
        data_brussel = {
            'name': 'projectname',
            'beginyear': 1234,
            'endyear': 5678,
            'url': 'https://github.com/vub-hpc/projectname',
        }
        for license in KNOWN_LICENSES.keys():
            res_fn = os.path.join(self.setup.REPO_TEST_DIR, 'headers', license)
            with open(res_fn) as fh:
                result = fh.read()
            gen_txt = gen_license_header(license, **data)
            self.assertEqual(
                gen_txt,
                result,
                msg='generated header for license %s as expected' % license)
            log.info('generated license header %s' % license)

            gen_txt_bru = gen_license_header(license, **data_brussel)
            self.assertNotRegexpMatches(
                gen_txt_bru,
                'Ghent University',
                msg='No reference to Ghent University in header')
            self.assertNotRegexpMatches(
                gen_txt_bru,
                r'ugent\.be',
                msg='No reference to ugent.be University in header')
            self.assertRegexpMatches(
                gen_txt_bru,
                r'the HPC team of Vrije Universiteit Brussel \(https://hpc.vub.be\)',
                msg='generted header for Brussel is correct for %s' % license)
            self.assertRegexpMatches(
                gen_txt_bru,
                r'support of Vrije Universiteit Brussel \(https://www.vub.be\)',
                msg='generted header for Brussel is correct for %s' % license)