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)
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)