def test_is_really_structured_from_file(self): assert not debian_copyright.is_really_structured(DebianCopyright.from_file(self.get_test_loc('dep5-pretend.copyright'))) assert not debian_copyright.is_really_structured(DebianCopyright.from_file(self.get_test_loc('dep5-not-dep5.copyright'))) # catchall are merged assert debian_copyright.is_really_structured(DebianCopyright.from_file(self.get_test_loc('dep5-pretend-5-catchall.copyright'))) assert debian_copyright.is_really_structured(DebianCopyright.from_file(self.get_test_loc('dep5-ok.copyright'))) assert debian_copyright.is_really_structured(DebianCopyright.from_file(self.get_test_loc('dep5-ok-header-only.copyright'))) assert debian_copyright.is_really_structured(DebianCopyright.from_file(self.get_test_loc('dep5-ok-mini.copyright'))) assert debian_copyright.is_really_structured(DebianCopyright.from_file(self.get_test_loc('dep5-ok.copyright')))
def test_get_duplicate_license_paras(self): test_file = self.get_test_loc('crafted_for_tests/test_duplicate_license_para_name') edebian_copyright = debian_copyright.EnhancedDebianCopyright(debian_copyright=DebianCopyright.from_file(test_file)) duplicate_paras = edebian_copyright.duplicate_license_paragraphs assert len(duplicate_paras) == 1 assert duplicate_paras[0].license.name == 'GPL-2+'
def test_multiple_blank_lines_is_valid_paragraph(self): test_file = self.get_test_loc('multiple-blank-lines.copyright') edebian_copyright = debian_copyright.EnhancedDebianCopyright(debian_copyright=DebianCopyright.from_file(test_file)) other_paras = edebian_copyright.other_paragraphs assert len(other_paras) == 1 assert other_paras[0].extra_data['unknown'] == 'This is a catchall para.'
def test_get_other_paras(self): test_file = self.get_test_loc('crafted_for_tests/test_other_paras') edebian_copyright = debian_copyright.EnhancedDebianCopyright(debian_copyright=DebianCopyright.from_file(test_file)) other_paras = edebian_copyright.other_paragraphs assert len(other_paras) == 1 assert other_paras[0].extra_data['unknown'] == 'Example of other paras.'
def test_get_paras_with_license_text(self): test_file = self.get_test_loc('debian-slim-2021-04-07/usr/share/doc/liblzma5/copyright') edebian_copyright = debian_copyright.EnhancedDebianCopyright(debian_copyright=DebianCopyright.from_file(test_file)) paras_with_license = edebian_copyright.paragraphs_with_license_text assert isinstance(paras_with_license[0], debian_copyright.CopyrightHeaderParagraph) assert isinstance(paras_with_license[1], debian_copyright.CopyrightFilesParagraph)
def test_get_license_paras(self): test_file = self.get_test_loc('debian-2019-11-15/main/c/cryptsetup/stable_copyright') edebian_copyright = debian_copyright.EnhancedDebianCopyright(debian_copyright=DebianCopyright.from_file(test_file)) license_paras = edebian_copyright.license_paragraphs assert len(license_paras) == 6 assert license_paras[0].license.name == 'GPL-2+'
def test_get_header_para(self): test_file = self.get_test_loc('debian-slim-2021-04-07/usr/share/doc/libhogweed6/copyright') edebian_copyright = debian_copyright.EnhancedDebianCopyright(debian_copyright=DebianCopyright.from_file(test_file)) header_para = edebian_copyright.header_paragraph assert header_para.license.name == 'LGPL-3+ or GPL-2+' assert header_para.upstream_name.value == 'Nettle' assert header_para.source.text == 'http://www.lysator.liu.se/~nisse/nettle/'
def test_is_paragraph_primary_license(self): test_file = self.get_test_loc('debian-slim-2021-04-07/usr/share/doc/libhogweed6/copyright') edebian_copyright = debian_copyright.EnhancedDebianCopyright(debian_copyright=DebianCopyright.from_file(test_file)) file_paras = edebian_copyright.file_paragraphs assert debian_copyright.is_paragraph_primary_license(file_paras[0])