Debian Codegraph @

tests/licenses_spdx_test.py

raw
1 #!/usr/bin/env python3
2
3 # Unit tests for decopy
4 # Copyright: 2018, Maximiliano Curia <[email protected]>
5 #
6 # License: ISC
7 # Permission to use, copy, modify, and/or distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
10 # .
11 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 # PERFORMANCE OF THIS SOFTWARE.
18
19 import json
20 import unittest
21 from pathlib import Path
22
23 from decopy.licensing import licenses
24
25
26 class TestSpdx(unittest.TestCase):
27 def _check_license_match(self, license_, matcher, expected, ignore=None):
28 for key in ("licenseText", "standardLicenseHeader", "licenseExceptionText"):
29 if key not in license_ or not license_[key]:
30 continue
31 if ignore and key in ignore:
32 continue
33 text = license_[key]
34 result = matcher(text)
35 self.assertEqual(result, expected, msg=f"with key={key}")
36
37 def _open_license_and_check(self, filename, matcher, expected, ignore=None):
38 with (Path("tests/testdata/licenses") / filename).open() as fp:
39 license_ = json.load(fp)
40 return self._check_license_match(license_, matcher, expected, ignore)
41
42 def _open_exception_and_check(self, filename, matcher, expected, ignore=None):
43 with (Path("tests/testdata/exceptions") / filename).open() as fp:
44 license_ = json.load(fp)
45 return self._check_license_match(license_, matcher, expected, ignore)
46
47 @staticmethod
48 def _find_licenses_matcher(text):
49 found = licenses.find_licenses(licenses.clean_comments(text))
50 return " or ".join(sorted(found))
51
52 def test_spdx_a(self):
53 self._open_license_and_check("AAL.json", self._find_licenses_matcher, "AAL")
54 self._open_license_and_check(
55 "Abstyles.json",
56 self._find_licenses_matcher,
57 "Abstyles",
58 )
59 self._open_license_and_check(
60 "Adobe-2006.json",
61 self._find_licenses_matcher,
62 "Adobe-2006",
63 )
64 self._open_license_and_check(
65 "Adobe-Glyph.json",
66 self._find_licenses_matcher,
67 "Adobe-Glyph",
68 )
69 self._open_license_and_check("ADSL.json", self._find_licenses_matcher, "ADSL")
70 self._open_license_and_check(
71 "AFL-1.1.json",
72 self._find_licenses_matcher,
73 "Academic-1.1",
74 )
75 self._open_license_and_check(
76 "AFL-1.2.json",
77 self._find_licenses_matcher,
78 "Academic-1.2",
79 )
80 self._open_license_and_check(
81 "AFL-2.0.json",
82 self._find_licenses_matcher,
83 "Academic-2",
84 )
85 self._open_license_and_check(
86 "AFL-2.1.json",
87 self._find_licenses_matcher,
88 "Academic-2.1",
89 )
90 self._open_license_and_check(
91 "AFL-3.0.json",
92 self._find_licenses_matcher,
93 "Academic-3",
94 )
95 self._open_license_and_check(
96 "Afmparse.json",
97 self._find_licenses_matcher,
98 "Afmparse",
99 )
100 self._open_license_and_check(
101 "Aladdin.json",
102 self._find_licenses_matcher,
103 "Aladdin",
104 )
105 self._open_license_and_check(
106 "AMDPLPA.json",
107 self._find_licenses_matcher,
108 "AMDPLPA",
109 )
110 self._open_license_and_check("AML.json", self._find_licenses_matcher, "AML")
111 self._open_license_and_check(
112 "AMPAS.json",
113 self._find_licenses_matcher,
114 "BSD-2-clause-AMPAS",
115 )
116 self._open_license_and_check(
117 "ANTLR-PD.json",
118 self._find_licenses_matcher,
119 "ANTLR-PD",
120 )
121 self._open_license_and_check(
122 "Apache-1.0.json",
123 self._find_licenses_matcher,
124 "Apache-1",
125 )
126 self._open_license_and_check(
127 "Apache-1.1.json",
128 self._find_licenses_matcher,
129 "Apache-1.1",
130 )
131 self._open_license_and_check(
132 "Apache-2.0.json",
133 self._find_licenses_matcher,
134 "Apache-2",
135 )
136 self._open_license_and_check(
137 "APAFML.json",
138 self._find_licenses_matcher,
139 "APAFML",
140 )
141 self._open_license_and_check(
142 "APL-1.0.json",
143 self._find_licenses_matcher,
144 "APL-1",
145 ignore={"standardLicenseHeader"},
146 )
147 self._open_license_and_check(
148 "APSL-1.0.json",
149 self._find_licenses_matcher,
150 "APSL-1",
151 )
152 self._open_license_and_check(
153 "APSL-1.1.json",
154 self._find_licenses_matcher,
155 "APSL-1.1",
156 )
157 self._open_license_and_check(
158 "APSL-1.2.json",
159 self._find_licenses_matcher,
160 "APSL-1.2",
161 )
162 self._open_license_and_check(
163 "APSL-2.0.json",
164 self._find_licenses_matcher,
165 "APSL-2",
166 )
167 self._open_license_and_check(
168 "Artistic-1.0-cl8.json",
169 self._find_licenses_matcher,
170 "Artistic-1-cl8",
171 )
172 self._open_license_and_check(
173 "Artistic-1.0-Perl.json",
174 self._find_licenses_matcher,
175 "Artistic-1-Perl",
176 )
177 self._open_license_and_check(
178 "Artistic-1.0.json",
179 self._find_licenses_matcher,
180 "Artistic-1",
181 )
182 self._open_license_and_check(
183 "Artistic-2.0.json",
184 self._find_licenses_matcher,
185 "Artistic-2",
186 )
187
188 def test_spdx_b(self):
189 self._open_license_and_check(
190 "Bahyph.json",
191 self._find_licenses_matcher,
192 "Bahyph",
193 )
194 self._open_license_and_check("Barr.json", self._find_licenses_matcher, "Barr")
195 self._open_license_and_check(
196 "BitTorrent-1.0.json",
197 self._find_licenses_matcher,
198 "BitTorrent-1",
199 )
200 self._open_license_and_check(
201 "BitTorrent-1.1.json",
202 self._find_licenses_matcher,
203 "BitTorrent-1.1",
204 # licenseText embeds the 1.0 preamble verbatim, which fools the
205 # version-capture regex into returning "BitTorrent-1".
206 # standardLicenseHeader correctly returns "BitTorrent-1.1".
207 ignore={"licenseText"},
208 )
209 self._open_license_and_check(
210 "Borceux.json",
211 self._find_licenses_matcher,
212 "Borceux",
213 )
214 self._open_license_and_check(
215 "BSL-1.0.json",
216 self._find_licenses_matcher,
217 "BSL-1",
218 )
219 self._open_license_and_check(
220 "bzip2-1.0.5.json",
221 self._find_licenses_matcher,
222 "BSD-like-bzip2-1.0.5",
223 )
224 self._open_license_and_check(
225 "bzip2-1.0.6.json",
226 self._find_licenses_matcher,
227 "BSD-like-bzip2-1.0.6",
228 )
229
230 def test_spdx_c(self):
231 self._open_license_and_check(
232 "Caldera.json",
233 self._find_licenses_matcher,
234 "Caldera",
235 )
236 self._open_license_and_check(
237 "CATOSL-1.1.json",
238 self._find_licenses_matcher,
239 "CATOSL-1.1",
240 )
241 self._open_license_and_check(
242 "CDDL-1.0.json",
243 self._find_licenses_matcher,
244 "CDDL-1",
245 )
246 self._open_license_and_check(
247 "CDDL-1.1.json",
248 self._find_licenses_matcher,
249 "CDDL-1.1",
250 )
251 self._open_license_and_check(
252 "CECILL-1.0.json",
253 self._find_licenses_matcher,
254 "CeCILL-1",
255 )
256 self._open_license_and_check(
257 "CECILL-1.1.json",
258 self._find_licenses_matcher,
259 "CeCILL-1.1",
260 )
261 self._open_license_and_check(
262 "CECILL-2.0.json",
263 self._find_licenses_matcher,
264 "CeCILL-2",
265 )
266 self._open_license_and_check(
267 "CECILL-2.1.json",
268 self._find_licenses_matcher,
269 "CeCILL-2.1",
270 )
271 self._open_license_and_check(
272 "CECILL-B.json",
273 self._find_licenses_matcher,
274 "CeCILL-B",
275 )
276 self._open_license_and_check(
277 "CECILL-C.json",
278 self._find_licenses_matcher,
279 "CeCILL-C",
280 )
281
282 self._open_license_and_check(
283 "ClArtistic.json",
284 self._find_licenses_matcher,
285 "ClArtistic",
286 )
287
288 self._open_license_and_check(
289 "CNRI-Jython.json",
290 self._find_licenses_matcher,
291 "CNRI-Jython",
292 )
293 self._open_license_and_check(
294 "CNRI-Python-GPL-Compatible.json",
295 self._find_licenses_matcher,
296 "CNRI-Python-GPL-Compatible",
297 )
298 self._open_license_and_check(
299 "CNRI-Python.json",
300 self._find_licenses_matcher,
301 "CNRI-Python",
302 )
303
304 self._open_license_and_check(
305 "Condor-1.1.json",
306 self._find_licenses_matcher,
307 "Condor-1.1",
308 )
309
310 self._open_license_and_check(
311 "CPAL-1.0.json",
312 self._find_licenses_matcher,
313 "CPAL-1",
314 )
315 self._open_license_and_check(
316 "CPL-1.0.json",
317 self._find_licenses_matcher,
318 "CPL-1",
319 )
320 self._open_license_and_check(
321 "CPOL-1.02.json",
322 self._find_licenses_matcher,
323 "CPOL-1.02",
324 )
325 self._open_license_and_check(
326 "Crossword.json",
327 self._find_licenses_matcher,
328 "Crossword",
329 )
330 self._open_license_and_check(
331 "CrystalStacker.json",
332 self._find_licenses_matcher,
333 "CrystalStacker",
334 )
335 self._open_license_and_check(
336 "CUA-OPL-1.0.json",
337 self._find_licenses_matcher,
338 "CUA-OPL-1",
339 )
340 self._open_license_and_check("Cube.json", self._find_licenses_matcher, "Cube")
341 self._open_license_and_check("curl.json", self._find_licenses_matcher, "curl")
342
343 def test_spdx_d(self):
344 self._open_license_and_check(
345 "D-FSL-1.0.json",
346 self._find_licenses_matcher,
347 "D-FSL",
348 )
349 self._open_license_and_check(
350 "diffmark.json",
351 self._find_licenses_matcher,
352 "diffmark",
353 )
354 self._open_license_and_check("DOC.json", self._find_licenses_matcher, "DOC")
355 self._open_license_and_check(
356 "Dotseqn.json",
357 self._find_licenses_matcher,
358 "Dotseqn",
359 )
360 self._open_license_and_check("DSDP.json", self._find_licenses_matcher, "DSDP")
361 self._open_license_and_check(
362 "dvipdfm.json",
363 self._find_licenses_matcher,
364 "dvipdfm",
365 )
366
367 def test_spdx_e(self):
368 self._open_license_and_check(
369 "ECL-1.0.json",
370 self._find_licenses_matcher,
371 "ECL-1",
372 )
373 self._open_license_and_check(
374 "ECL-2.0.json",
375 self._find_licenses_matcher,
376 "ECL-2",
377 )
378 self._open_license_and_check(
379 "eCos-2.0.json",
380 self._find_licenses_matcher,
381 "GPL-2+ with eCos-2 exception",
382 )
383 self._open_license_and_check(
384 "EFL-1.0.json",
385 self._find_licenses_matcher,
386 "EFL-1",
387 )
388 self._open_license_and_check(
389 "EFL-2.0.json",
390 self._find_licenses_matcher,
391 "EFL-2",
392 )
393 self._open_license_and_check(
394 "eGenix.json",
395 self._find_licenses_matcher,
396 "eGenix",
397 )
398 self._open_license_and_check(
399 "Entessa.json",
400 self._find_licenses_matcher,
401 "BSD-like-Entessa",
402 )
403 self._open_license_and_check(
404 "EPL-1.0.json",
405 self._find_licenses_matcher,
406 "EPL-1",
407 )
408 self._open_license_and_check(
409 "ErlPL-1.1.json",
410 self._find_licenses_matcher,
411 "ErlPL-1.1",
412 )
413 self._open_license_and_check(
414 "EUDatagrid.json",
415 self._find_licenses_matcher,
416 "EUDatagrid",
417 )
418 self._open_license_and_check(
419 "EUPL-1.0.json",
420 self._find_licenses_matcher,
421 "EUPL-1",
422 )
423 self._open_license_and_check(
424 "EUPL-1.1.json",
425 self._find_licenses_matcher,
426 "EUPL-1.1",
427 )
428 self._open_license_and_check(
429 "Eurosym.json",
430 self._find_licenses_matcher,
431 "Eurosym",
432 )
433
434 def test_spdx_f(self):
435 self._open_license_and_check("Fair.json", self._find_licenses_matcher, "Fair")
436 self._open_license_and_check(
437 "Frameworx-1.0.json",
438 self._find_licenses_matcher,
439 "Frameworx-1",
440 )
441 self._open_license_and_check(
442 "FreeImage.json",
443 self._find_licenses_matcher,
444 "FreeImage-1",
445 )
446 self._open_license_and_check("FSFAP.json", self._find_licenses_matcher, "FSFAP")
447 self._open_license_and_check("FSFUL.json", self._find_licenses_matcher, "FSFUL")
448 self._open_license_and_check(
449 "FSFULLR.json",
450 self._find_licenses_matcher,
451 "FSFULLR",
452 )
453 self._open_license_and_check("FTL.json", self._find_licenses_matcher, "FTL")
454
455 def test_spdx_g(self):
456 self._open_license_and_check(
457 "GFDL-1.1.json",
458 self._find_licenses_matcher,
459 "GFDL-1.1+",
460 ignore={"licenseText"},
461 )
462 self._open_license_and_check(
463 "GFDL-1.2.json",
464 self._find_licenses_matcher,
465 "GFDL-NIV-1.2+",
466 )
467 self._open_license_and_check(
468 "GFDL-1.3.json",
469 self._find_licenses_matcher,
470 "GFDL-NIV-1.3+",
471 )
472 self._open_license_and_check(
473 "Giftware.json",
474 self._find_licenses_matcher,
475 "Giftware",
476 )
477 self._open_license_and_check("GL2PS.json", self._find_licenses_matcher, "GL2PS")
478 self._open_license_and_check("Glide.json", self._find_licenses_matcher, "Glide")
479 self._open_license_and_check(
480 "Glulxe.json",
481 self._find_licenses_matcher,
482 "Glulxe",
483 )
484 self._open_license_and_check(
485 "gnuplot.json",
486 self._find_licenses_matcher,
487 "gnuplot",
488 )
489 self._open_license_and_check(
490 "gSOAP-1.3b.json",
491 self._find_licenses_matcher,
492 "gSOAP-1.3",
493 )
494
495 def test_spdx_h(self):
496 self._open_license_and_check(
497 "HaskellReport.json",
498 self._find_licenses_matcher,
499 "HaskellReport",
500 )
501 self._open_license_and_check(
502 "HPND.json", self._find_licenses_matcher, "MIT-like-HPND"
503 )
504
505 def test_spdx_i(self):
506 self._open_license_and_check(
507 "IBM-pibs.json",
508 self._find_licenses_matcher,
509 "IBM-pibs",
510 )
511 self._open_license_and_check(
512 "ICU.json",
513 self._find_licenses_matcher,
514 "MIT-like-icu",
515 )
516 self._open_license_and_check("IJG.json", self._find_licenses_matcher, "IJG")
517 self._open_license_and_check(
518 "ImageMagick.json",
519 self._find_licenses_matcher,
520 "ImageMagick",
521 )
522 self._open_license_and_check(
523 "iMatix.json",
524 self._find_licenses_matcher,
525 "iMatix",
526 )
527 self._open_license_and_check(
528 "Imlib2.json",
529 self._find_licenses_matcher,
530 "MIT-Imlib2",
531 )
532 self._open_license_and_check(
533 "Info-ZIP.json",
534 self._find_licenses_matcher,
535 "Info-ZIP",
536 )
537 self._open_license_and_check(
538 "Intel-ACPI.json",
539 self._find_licenses_matcher,
540 "Intel-ACPI",
541 )
542 self._open_license_and_check("Intel.json", self._find_licenses_matcher, "Intel")
543 self._open_license_and_check(
544 "Interbase-1.0.json",
545 self._find_licenses_matcher,
546 "Interbase-1",
547 )
548 self._open_license_and_check("IPA.json", self._find_licenses_matcher, "IPA-1")
549 self._open_license_and_check(
550 "IPL-1.0.json",
551 self._find_licenses_matcher,
552 "IPL-1",
553 )
554 self._open_license_and_check("ISC.json", self._find_licenses_matcher, "ISC")
555
556 def test_spdx_j(self):
557 self._open_license_and_check(
558 "JasPer-2.0.json",
559 self._find_licenses_matcher,
560 "JasPer-2",
561 )
562 self._open_license_and_check("JSON.json", self._find_licenses_matcher, "JSON")
563
564 def test_spdx_l(self):
565 self._open_license_and_check(
566 "LAL-1.2.json",
567 self._find_licenses_matcher,
568 "LAL-1.2",
569 )
570 self._open_license_and_check(
571 "LAL-1.3.json",
572 self._find_licenses_matcher,
573 "LAL-1.3",
574 )
575 self._open_license_and_check(
576 "Latex2e.json",
577 self._find_licenses_matcher,
578 "Latex2e",
579 )
580 self._open_license_and_check(
581 "Leptonica.json",
582 self._find_licenses_matcher,
583 "Leptonica",
584 )
585 self._open_license_and_check(
586 "Libpng.json",
587 self._find_licenses_matcher,
588 "Libpng",
589 )
590 self._open_license_and_check(
591 "libtiff.json",
592 self._find_licenses_matcher,
593 "libtiff",
594 )
595 self._open_license_and_check(
596 "LiLiQ-P-1.1.json",
597 self._find_licenses_matcher,
598 "LiLiQ-P-1.1",
599 )
600 self._open_license_and_check(
601 "LiLiQ-R-1.1.json",
602 self._find_licenses_matcher,
603 "LiLiQ-R-1.1",
604 )
605 self._open_license_and_check(
606 "LiLiQ-Rplus-1.1.json",
607 self._find_licenses_matcher,
608 "LiLiQ-R+-1.1",
609 )
610 self._open_license_and_check(
611 "LPL-1.0.json",
612 self._find_licenses_matcher,
613 "LPL-1",
614 )
615 self._open_license_and_check(
616 "LPL-1.02.json",
617 self._find_licenses_matcher,
618 "LPL-1.02",
619 )
620
621 def test_spdx_m(self):
622 self._open_license_and_check(
623 "MakeIndex.json",
624 self._find_licenses_matcher,
625 "MakeIndex",
626 )
627 self._open_license_and_check("MirOS.json", self._find_licenses_matcher, "MirOS")
628 self._open_license_and_check(
629 "Motosoto.json",
630 self._find_licenses_matcher,
631 "Motosoto",
632 ignore={"standardLicenseHeader"},
633 )
634 self._open_license_and_check(
635 "mpich2.json",
636 self._find_licenses_matcher,
637 "mpich",
638 )
639 self._open_license_and_check(
640 "MPL-1.0.json",
641 self._find_licenses_matcher,
642 "MPL-1",
643 )
644 self._open_license_and_check(
645 "MPL-1.1.json",
646 self._find_licenses_matcher,
647 "MPL-1.1",
648 )
649 self._open_license_and_check(
650 "MPL-2.0-no-copyleft-exception.json",
651 self._find_licenses_matcher,
652 "MPL-2 with no-copyleft exception",
653 ignore={"licenseText"},
654 )
655 self._open_license_and_check(
656 "MPL-2.0.json",
657 self._find_licenses_matcher,
658 "MPL-2",
659 )
660 self._open_license_and_check("MS-PL.json", self._find_licenses_matcher, "MS-PL")
661 self._open_license_and_check("MS-RL.json", self._find_licenses_matcher, "MS-RL")
662 self._open_license_and_check("MTLL.json", self._find_licenses_matcher, "MTLL")
663 self._open_license_and_check(
664 "Multics.json",
665 self._find_licenses_matcher,
666 "Multics",
667 )
668 self._open_license_and_check(
669 "Mup.json",
670 self._find_licenses_matcher,
671 "BSD-like-Mup",
672 )
673
674 def test_spdx_n(self):
675 self._open_license_and_check(
676 "NASA-1.3.json",
677 self._find_licenses_matcher,
678 "NASA-1.3",
679 )
680 self._open_license_and_check(
681 "Naumen.json",
682 self._find_licenses_matcher,
683 "Naumen",
684 )
685 self._open_license_and_check(
686 "NBPL-1.0.json",
687 self._find_licenses_matcher,
688 "NBPL-1",
689 )
690 self._open_license_and_check("NCSA.json", self._find_licenses_matcher, "NCSA")
691 self._open_license_and_check(
692 "NetCDF.json",
693 self._find_licenses_matcher,
694 "NetCDF",
695 )
696 self._open_license_and_check(
697 "Newsletr.json",
698 self._find_licenses_matcher,
699 "Newsletr",
700 )
701 self._open_license_and_check("NGPL.json", self._find_licenses_matcher, "NGPL")
702 self._open_license_and_check(
703 "NLOD-1.0.json",
704 self._find_licenses_matcher,
705 "NLOD-1",
706 )
707 self._open_license_and_check("NLPL.json", self._find_licenses_matcher, "NLPL")
708 self._open_license_and_check(
709 "Nokia.json",
710 self._find_licenses_matcher,
711 "Nokia",
712 )
713 self._open_license_and_check(
714 "Net-SNMP.json",
715 self._find_licenses_matcher,
716 "Net-SNMP",
717 )
718 self._open_license_and_check("NOSL.json", self._find_licenses_matcher, "NOSL-1")
719 self._open_license_and_check("Noweb.json", self._find_licenses_matcher, "Noweb")
720 self._open_license_and_check(
721 "NPL-1.0.json",
722 self._find_licenses_matcher,
723 "NPL-1",
724 )
725 # The header included in the file is NPL-1
726 self._open_license_and_check(
727 "NPL-1.1.json",
728 self._find_licenses_matcher,
729 "MPL-1.1_NPL-1.1",
730 ignore={"standardLicenseHeader"},
731 )
732 self._open_license_and_check(
733 "NPOSL-3.0.json",
734 self._find_licenses_matcher,
735 "NPOSL-3",
736 )
737 self._open_license_and_check("NRL.json", self._find_licenses_matcher, "NRL")
738 self._open_license_and_check("NTP.json", self._find_licenses_matcher, "NTP")
739 self._open_license_and_check(
740 "Nunit.json",
741 self._find_licenses_matcher,
742 "Zlib-acknowledgement",
743 )
744
745 def test_spdx_o(self):
746 self._open_license_and_check(
747 "OCCT-PL.json",
748 self._find_licenses_matcher,
749 "OCCT-PL",
750 )
751 self._open_license_and_check(
752 "OCLC-2.0.json",
753 self._find_licenses_matcher,
754 "OCLC-2",
755 )
756 self._open_license_and_check(
757 "ODbL-1.0.json",
758 self._find_licenses_matcher,
759 "ODbL-1",
760 )
761 self._open_license_and_check(
762 "OFL-1.0.json",
763 self._find_licenses_matcher,
764 "OFL-1",
765 )
766 self._open_license_and_check(
767 "OFL-1.1.json",
768 self._find_licenses_matcher,
769 "OFL-1.1",
770 )
771 self._open_license_and_check("OGTSL.json", self._find_licenses_matcher, "OGTSL")
772 self._open_license_and_check(
773 "OLDAP-1.1.json",
774 self._find_licenses_matcher,
775 "OLDAP-1.1",
776 )
777 self._open_license_and_check(
778 "OLDAP-1.2.json",
779 self._find_licenses_matcher,
780 "OLDAP-1.2",
781 )
782 self._open_license_and_check(
783 "OLDAP-1.3.json",
784 self._find_licenses_matcher,
785 "OLDAP-1.3",
786 )
787 self._open_license_and_check(
788 "OLDAP-1.4.json",
789 self._find_licenses_matcher,
790 "OLDAP-1.4",
791 )
792 self._open_license_and_check(
793 "OLDAP-2.0.1.json",
794 self._find_licenses_matcher,
795 "OLDAP-2.0.1",
796 )
797 self._open_license_and_check(
798 "OLDAP-2.0.json",
799 self._find_licenses_matcher,
800 "OLDAP-2",
801 )
802 self._open_license_and_check(
803 "OLDAP-2.1.json",
804 self._find_licenses_matcher,
805 "OLDAP-2.1",
806 )
807 self._open_license_and_check(
808 "OLDAP-2.2.1.json",
809 self._find_licenses_matcher,
810 "OLDAP-2.2.1",
811 )
812 self._open_license_and_check(
813 "OLDAP-2.2.2.json",
814 self._find_licenses_matcher,
815 "OLDAP-2.2.2",
816 )
817 self._open_license_and_check(
818 "OLDAP-2.2.json",
819 self._find_licenses_matcher,
820 "OLDAP-2.2",
821 )
822 self._open_license_and_check(
823 "OLDAP-2.3.json",
824 self._find_licenses_matcher,
825 "OLDAP-2.3",
826 )
827 self._open_license_and_check(
828 "OLDAP-2.4.json",
829 self._find_licenses_matcher,
830 "OLDAP-2.4",
831 )
832 self._open_license_and_check(
833 "OLDAP-2.5.json",
834 self._find_licenses_matcher,
835 "OLDAP-2.5",
836 )
837 self._open_license_and_check(
838 "OLDAP-2.6.json",
839 self._find_licenses_matcher,
840 "OLDAP-2.6",
841 )
842 self._open_license_and_check(
843 "OLDAP-2.7.json",
844 self._find_licenses_matcher,
845 "OLDAP-2.7",
846 )
847 self._open_license_and_check(
848 "OLDAP-2.8.json",
849 self._find_licenses_matcher,
850 "OLDAP-2.8",
851 )
852 self._open_license_and_check("OML.json", self._find_licenses_matcher, "OML")
853 # The dual OpenSSL+SSLeay licence reports the single OpenSSL id: the
854 # embedded SSLeay (BSD family) is suppressed when the OpenSSL Project
855 # marker is present.
856 self._open_license_and_check(
857 "OpenSSL.json",
858 self._find_licenses_matcher,
859 "OpenSSL",
860 )
861 self._open_license_and_check(
862 "OPL-1.0.json",
863 self._find_licenses_matcher,
864 "OPL-1",
865 )
866 self._open_license_and_check(
867 "OSET-PL-2.1.json",
868 self._find_licenses_matcher,
869 "OSET-PL-2.1",
870 )
871 self._open_license_and_check(
872 "OSL-1.0.json",
873 self._find_licenses_matcher,
874 "OSL-1",
875 )
876 self._open_license_and_check(
877 "OSL-1.1.json",
878 self._find_licenses_matcher,
879 "OSL-1.1",
880 )
881 self._open_license_and_check(
882 "OSL-2.0.json",
883 self._find_licenses_matcher,
884 "OSL-2",
885 )
886 self._open_license_and_check(
887 "OSL-2.1.json",
888 self._find_licenses_matcher,
889 "OSL-2.1",
890 )
891 self._open_license_and_check(
892 "OSL-3.0.json",
893 self._find_licenses_matcher,
894 "OSL-3",
895 )
896
897 def test_spdx_p(self):
898 self._open_license_and_check(
899 "PDDL-1.0.json",
900 self._find_licenses_matcher,
901 "PDDL-1",
902 )
903 self._open_license_and_check(
904 "PHP-3.0.json",
905 self._find_licenses_matcher,
906 "PHP-3",
907 )
908 self._open_license_and_check(
909 "PHP-3.01.json",
910 self._find_licenses_matcher,
911 "PHP-3.01",
912 )
913 self._open_license_and_check(
914 "Plexus.json",
915 self._find_licenses_matcher,
916 "Plexus",
917 )
918 self._open_license_and_check(
919 "PostgreSQL.json",
920 self._find_licenses_matcher,
921 "PostgreSQL",
922 )
923 self._open_license_and_check(
924 "psfrag.json",
925 self._find_licenses_matcher,
926 "psfrag",
927 )
928 self._open_license_and_check(
929 "psutils.json",
930 self._find_licenses_matcher,
931 "psutils",
932 )
933 self._open_license_and_check(
934 "PSF-2.0.json",
935 self._find_licenses_matcher,
936 "PSF-2",
937 )
938 # The 2.0 / 2.0.1 collections suppress their embedded CNRI and CWI/MIT
939 # parts so each is reported under its single Python id.
940 self._open_license_and_check(
941 "Python-2.0.json",
942 self._find_licenses_matcher,
943 "Python-2",
944 )
945 self._open_license_and_check(
946 "Python-2.0.1.json",
947 self._find_licenses_matcher,
948 "Python-2.0.1",
949 )
950
951 def test_spdx_q(self):
952 self._open_license_and_check("Qhull.json", self._find_licenses_matcher, "Qhull")
953 self._open_license_and_check(
954 "QPL-1.0.json",
955 self._find_licenses_matcher,
956 "QPL-1",
957 )
958
959 def test_spdx_r(self):
960 self._open_license_and_check("Rdisc.json", self._find_licenses_matcher, "Rdisc")
961 self._open_license_and_check(
962 "RHeCos-1.1.json",
963 self._find_licenses_matcher,
964 "RHeCos-1.1",
965 )
966 self._open_license_and_check(
967 "RPL-1.1.json",
968 self._find_licenses_matcher,
969 "RPL-1.1",
970 )
971 self._open_license_and_check(
972 "RPL-1.5.json",
973 self._find_licenses_matcher,
974 "RPL-1.5",
975 )
976 self._open_license_and_check(
977 "RPSL-1.0.json",
978 self._find_licenses_matcher,
979 "RPSL-1",
980 )
981 self._open_license_and_check(
982 "RSA-MD.json",
983 self._find_licenses_matcher,
984 "RSA-MD",
985 )
986 self._open_license_and_check(
987 "RSCPL.json",
988 self._find_licenses_matcher,
989 "RSCPL-1",
990 )
991 self._open_license_and_check("Ruby.json", self._find_licenses_matcher, "Ruby")
992
993 def test_spdx_s(self):
994 self._open_license_and_check(
995 "SAX-PD.json",
996 self._find_licenses_matcher,
997 "SAX-PD",
998 )
999 self._open_license_and_check(
1000 "Saxpath.json",
1001 self._find_licenses_matcher,
1002 "BSD-like-Saxpath",
1003 )
1004 self._open_license_and_check("SCEA.json", self._find_licenses_matcher, "SCEA-1")
1005 self._open_license_and_check(
1006 "Sendmail.json",
1007 self._find_licenses_matcher,
1008 "Sendmail",
1009 )
1010 self._open_license_and_check(
1011 "SGI-B-1.0.json",
1012 self._find_licenses_matcher,
1013 "SGI-B-1",
1014 )
1015 self._open_license_and_check(
1016 "SGI-B-1.1.json",
1017 self._find_licenses_matcher,
1018 "SGI-B-1.1",
1019 )
1020 self._open_license_and_check(
1021 "SGI-B-2.0.json",
1022 self._find_licenses_matcher,
1023 "SGI-B-2",
1024 )
1025 self._open_license_and_check(
1026 "SimPL-2.0.json",
1027 self._find_licenses_matcher,
1028 "SimPL-2",
1029 )
1030 self._open_license_and_check(
1031 "SISSL-1.2.json",
1032 self._find_licenses_matcher,
1033 "SISSL-1.2",
1034 )
1035 self._open_license_and_check(
1036 "SISSL.json",
1037 self._find_licenses_matcher,
1038 "SISSL-1.1",
1039 )
1040 self._open_license_and_check(
1041 "Sleepycat.json",
1042 self._find_licenses_matcher,
1043 "Sleepycat",
1044 )
1045 self._open_license_and_check(
1046 "SMLNJ.json",
1047 self._find_licenses_matcher,
1048 "MIT-like-SMLNJ",
1049 )
1050 self._open_license_and_check("SMPPL.json", self._find_licenses_matcher, "SMPPL")
1051 self._open_license_and_check("SNIA.json", self._find_licenses_matcher, "SNIA-1")
1052 self._open_license_and_check(
1053 "Spencer-86.json",
1054 self._find_licenses_matcher,
1055 "Spencer-86",
1056 )
1057 self._open_license_and_check(
1058 "Spencer-94.json",
1059 self._find_licenses_matcher,
1060 "Spencer-94",
1061 )
1062 self._open_license_and_check(
1063 "Spencer-99.json",
1064 self._find_licenses_matcher,
1065 "Spencer-99",
1066 )
1067 self._open_license_and_check(
1068 "SPL-1.0.json",
1069 self._find_licenses_matcher,
1070 "SPL-1",
1071 )
1072 self._open_license_and_check(
1073 "StandardML-NJ.json",
1074 self._find_licenses_matcher,
1075 "MIT-like-SMLNJ",
1076 )
1077 self._open_license_and_check(
1078 "SugarCRM-1.1.3.json",
1079 self._find_licenses_matcher,
1080 "SugarCRM-1.1.3",
1081 )
1082 self._open_license_and_check("SWL.json", self._find_licenses_matcher, "SWL")
1083
1084 def test_spdx_t(self):
1085 self._open_license_and_check("TCL.json", self._find_licenses_matcher, "TCL")
1086 self._open_license_and_check(
1087 "TMate.json",
1088 self._find_licenses_matcher,
1089 "BSD-like-TMate",
1090 )
1091 self._open_license_and_check(
1092 "TORQUE-1.1.json",
1093 self._find_licenses_matcher,
1094 "TORQUE-1.1",
1095 )
1096 self._open_license_and_check(
1097 "TOSL.json",
1098 self._find_licenses_matcher,
1099 "BSD-like-TOSL",
1100 )
1101
1102 def test_spdx_u(self):
1103 self._open_license_and_check(
1104 "Unicode-TOU.json",
1105 self._find_licenses_matcher,
1106 "Unicode-TOU",
1107 )
1108 self._open_license_and_check(
1109 "Unlicense.json",
1110 self._find_licenses_matcher,
1111 "Unlicense",
1112 )
1113 self._open_license_and_check(
1114 "UPL-1.0.json",
1115 self._find_licenses_matcher,
1116 "UPL-1",
1117 )
1118
1119 def test_spdx_v(self):
1120 self._open_license_and_check("Vim.json", self._find_licenses_matcher, "Vim")
1121 self._open_license_and_check(
1122 "VOSTROM.json",
1123 self._find_licenses_matcher,
1124 "VOSTROM",
1125 )
1126 self._open_license_and_check(
1127 "VSL-1.0.json",
1128 self._find_licenses_matcher,
1129 "VSL-1",
1130 )
1131
1132 def test_spdx_w(self):
1133 self._open_license_and_check(
1134 "W3C.json",
1135 self._find_licenses_matcher,
1136 "W3C",
1137 ignore={"standardLicenseHeader"},
1138 )
1139 self._open_license_and_check(
1140 "Watcom-1.0.json",
1141 self._find_licenses_matcher,
1142 "Watcom-1",
1143 )
1144 self._open_license_and_check(
1145 "Wsuipa.json",
1146 self._find_licenses_matcher,
1147 "Wsuipa",
1148 )
1149 self._open_license_and_check("WTFPL.json", self._find_licenses_matcher, "WTFPL")
1150 # wxWindows.json (deprecated SPDX ID) now contains only the exception
1151 # notice, not the combined LGPL+exception text of the old data.
1152 self._open_license_and_check(
1153 "wxWindows.json",
1154 self._find_licenses_matcher,
1155 "",
1156 )
1157
1158 def test_spdx_x(self):
1159 self._open_license_and_check("X11.json", self._find_licenses_matcher, "X11")
1160 self._open_license_and_check("Xerox.json", self._find_licenses_matcher, "Xerox")
1161 self._open_license_and_check(
1162 "XFree86-1.1.json",
1163 self._find_licenses_matcher,
1164 "XFree86-1.1",
1165 )
1166 self._open_license_and_check(
1167 "xinetd.json",
1168 self._find_licenses_matcher,
1169 "xinetd",
1170 )
1171 self._open_license_and_check("Xnet.json", self._find_licenses_matcher, "Expat")
1172 self._open_license_and_check("xpp.json", self._find_licenses_matcher, "xpp")
1173 self._open_license_and_check("XSkat.json", self._find_licenses_matcher, "XSkat")
1174
1175 def test_spdx_y(self):
1176 self._open_license_and_check(
1177 "YPL-1.0.json",
1178 self._find_licenses_matcher,
1179 "YPL-1",
1180 )
1181 self._open_license_and_check(
1182 "YPL-1.1.json",
1183 self._find_licenses_matcher,
1184 "YPL-1.1",
1185 )
1186
1187 def test_spdx_z(self):
1188 self._open_license_and_check("Zed.json", self._find_licenses_matcher, "Zed")
1189 self._open_license_and_check(
1190 "Zend-2.0.json",
1191 self._find_licenses_matcher,
1192 "Zend-2",
1193 )
1194 self._open_license_and_check(
1195 "Zimbra-1.3.json",
1196 self._find_licenses_matcher,
1197 "Zimbra-1.3",
1198 )
1199 self._open_license_and_check(
1200 "Zimbra-1.4.json",
1201 self._find_licenses_matcher,
1202 "Zimbra-1.4",
1203 )
1204 self._open_license_and_check(
1205 "zlib-acknowledgement.json",
1206 self._find_licenses_matcher,
1207 "Zlib-acknowledgement",
1208 )
1209 self._open_license_and_check("Zlib.json", self._find_licenses_matcher, "Zlib")
1210 self._open_license_and_check(
1211 "ZPL-1.1.json",
1212 self._find_licenses_matcher,
1213 "ZPL-1.1",
1214 )
1215 self._open_license_and_check(
1216 "ZPL-2.0.json",
1217 self._find_licenses_matcher,
1218 "ZPL-2",
1219 )
1220 self._open_license_and_check(
1221 "ZPL-2.1.json",
1222 self._find_licenses_matcher,
1223 "ZPL-2.1",
1224 )
1225
1226
1227 class TestSpdxExceptions(unittest.TestCase):
1228 @staticmethod
1229 def _load_license(spdx_id):
1230 d = json.loads(
1231 (Path("tests/testdata/licenses") / f"{spdx_id}.json").read_text()
1232 )
1233 return d.get("standardLicenseHeader") or d["licenseText"]
1234
1235 @staticmethod
1236 def _load_exception(filename):
1237 d = json.loads((Path("tests/testdata/exceptions") / filename).read_text())
1238 return d["licenseExceptionText"]
1239
1240 @staticmethod
1241 def _gpl_matcher(text):
1242 from decopy.licensing import license_parsers, licenses
1243
1244 return license_parsers.parse_gpl(licenses.clean_comments(text), None, "GPL")
1245
1246 @staticmethod
1247 def _agpl_matcher(text):
1248 from decopy.licensing import license_parsers, licenses
1249
1250 return license_parsers.parse_gpl(licenses.clean_comments(text), None, "AGPL")
1251
1252 @staticmethod
1253 def _lgpl_matcher(text):
1254 from decopy.licensing import license_parsers, licenses
1255
1256 return license_parsers.parse_gpl(licenses.clean_comments(text), None, "LGPL")
1257
1258 @staticmethod
1259 def _apache_matcher(text):
1260 from decopy.licensing import license_parsers, licenses
1261
1262 return license_parsers.parse_apache(
1263 licenses.clean_comments(text), None, "Apache"
1264 )
1265
1266 @staticmethod
1267 def _mit_matcher(text):
1268 from decopy.licensing import license_parsers, license_subs, licenses
1269
1270 return license_parsers.parse_exceptions(
1271 licenses.clean_comments(text), "MIT", license_subs.MIT_EXCEPTION_SUBS
1272 )
1273
1274 @staticmethod
1275 def _cc_by_sa_matcher(text):
1276 from decopy.licensing import license_parsers, license_subs, licenses
1277
1278 return license_parsers.parse_exceptions(
1279 licenses.clean_comments(text),
1280 "CC-BY-SA",
1281 license_subs.CC_BY_SA_EXCEPTION_SUBS,
1282 )
1283
1284 @staticmethod
1285 def _qpl_matcher(text):
1286 from decopy.licensing import license_parsers, licenses
1287
1288 return license_parsers.parse_qpl(licenses.clean_comments(text), None, "QPL")
1289
1290 @staticmethod
1291 def _bsd_matcher(text):
1292 from decopy.licensing import license_parsers, license_subs, licenses
1293
1294 return license_parsers.parse_exceptions(
1295 licenses.clean_comments(text), "BSD", license_subs.BSD_EXCEPTION_SUBS
1296 )
1297
1298 def _check(self, filename, expected, matcher=None):
1299 if matcher is None:
1300 matcher = self._gpl_matcher
1301 with (Path("tests/testdata/exceptions") / filename).open() as fp:
1302 d = json.load(fp)
1303 result = matcher(d["licenseExceptionText"])
1304 self.assertEqual(result, expected)
1305
1306 def test_autoconf_passes(self):
1307 self._check("389-exception.json", "GPL-2 with 389 exception")
1308 self._check("Autoconf-exception-2.0.json", "GPL with AutoConf exception")
1309 self._check("Autoconf-exception-generic.json", "GPL with AutoConf exception")
1310 self._check("Classpath-exception-2.0.json", "GPL with ClassPath exception")
1311 self._check(
1312 "Classpath-exception-2.0-short.json", "GPL with ClassPath exception"
1313 )
1314 self._check("Fawkes-Runtime-exception.json", "GPL with ClassPath_MIF exception")
1315
1316 def test_gcc_passes(self):
1317 self._check("GCC-exception-2.0.json", "GPL with GCC exception")
1318 self._check("CLISP-exception-2.0.json", "GPL-2 with CLISP exception")
1319 self._check("DigiRule-FOSS-exception.json", "GPL with DigiRule-FOSS exception")
1320 self._check("eCos-exception-2.0.json", "GPL with eCos-2 exception")
1321 self._check("FLTK-exception.json", "GPL with FLTK exception")
1322 self._check("Font-exception-2.0.json", "GPL with Font exception")
1323 self._check("freertos-exception-2.0.json", "GPL with FreeRTOS exception")
1324 self._check("gnu-javamail-exception.json", "GPL with GNU-JavaMail exception")
1325 self._check("i2p-gpl-java-exception.json", "GPL with i2p-Java exception")
1326 self._check("Libtool-exception.json", "GPL with LibTool exception")
1327 self._check("LZMA-exception.json", "GPL with LZMA exception")
1328 self._check("mif-exception.json", "GPL with MIF exception")
1329 self._check("Bison-exception-2.2.json", "GPL with Bison exception")
1330 self._check("u-boot-exception-2.0.json", "GPL with u-boot exception")
1331
1332 # --- xfail entries (matcher changes needed in 5a) ---
1333
1334 def test_autoconf_3(self):
1335 self._check("Autoconf-exception-3.0.json", "GPL-3 with AutoConf-3 exception")
1336
1337 def test_autoconf_generic_3(self):
1338 self._check(
1339 "Autoconf-exception-generic-3.0.json", "GPL-3 with AutoConf-3 exception"
1340 )
1341
1342 def test_autoconf_macro(self):
1343 self._check(
1344 "Autoconf-exception-macro.json", "GPL with AutoConf-macro exception"
1345 )
1346
1347 def test_bison_1_24(self):
1348 self._check("Bison-exception-1.24.json", "GPL with Bison-1.24 exception")
1349
1350 def test_classpath_independent_modules(self):
1351 self._check(
1352 "Independent-modules-exception.json",
1353 "GPL with Independent-modules exception",
1354 )
1355
1356 def test_gcc_note(self):
1357 self._check("GCC-exception-2.0-note.json", "GPL with GCC exception")
1358
1359 def test_gcc_3_1(self):
1360 self._check("GCC-exception-3.1.json", "GPL-3 with GCC-3.1 exception")
1361
1362 def test_gnat(self):
1363 self._check("GNAT-exception.json", "GPL with GNAT exception")
1364
1365 def test_gnu_compiler(self):
1366 self._check("GNU-compiler-exception.json", "GPL with GNU-compiler exception")
1367
1368 def test_gpl_cc(self):
1369 self._check("GPL-CC-1.0.json", "GPL-2 with GPL-CC exception")
1370
1371 def test_gpl_cc_combined(self):
1372 """Combined license header + GPL-CC: version comes from the base licence."""
1373 gplcc = self._load_exception("GPL-CC-1.0.json")
1374
1375 for lic_id, group, expected in [
1376 ("LGPL-2.1", "LGPL", "LGPL-2.1 with GPL-CC exception"),
1377 ("LGPL-2.0", "LGPL", "LGPL-2 with GPL-CC exception"),
1378 ("GPL-2.0", "GPL", "GPL-2 with GPL-CC exception"),
1379 ]:
1380 with self.subTest(lic_id=lic_id):
1381 lic = self._load_license(lic_id)
1382 combined = lic + "\n\n" + gplcc
1383 from decopy.licensing import license_parsers, licenses
1384
1385 result = license_parsers.parse_gpl(
1386 licenses.clean_comments(combined), None, group
1387 )
1388 self.assertEqual(result, expected)
1389
1390 def test_gpl3_linking(self):
1391 self._check(
1392 "GPL-3.0-linking-exception.json", "GPL-3 with GPL-3-linking exception"
1393 )
1394
1395 def test_gpl3_linking_source(self):
1396 self._check(
1397 "GPL-3.0-linking-source-exception.json",
1398 "GPL-3 with GPL-3-linking-source exception",
1399 )
1400
1401 def test_gpl3_interface(self):
1402 self._check(
1403 "GPL-3.0-interface-exception.json", "GPL-3 with GPL-3-interface exception"
1404 )
1405
1406 def test_gpl3_389_ds(self):
1407 self._check(
1408 "GPL-3.0-389-ds-base-exception.json", "GPL with GPL-3-389-ds exception"
1409 )
1410
1411 def test_gstreamer_2005(self):
1412 self._check("GStreamer-exception-2005.json", "GPL with GStreamer exception")
1413
1414 def test_gstreamer_2008(self):
1415 self._check("GStreamer-exception-2008.json", "GPL with GStreamer exception")
1416
1417 def test_gmsh(self):
1418 self._check("Gmsh-exception.json", "GPL with Gmsh exception")
1419
1420 def test_linux_syscall(self):
1421 self._check("Linux-syscall-note.json", "GPL with Linux-syscall exception")
1422
1423 def test_erlang_otp(self):
1424 self._check(
1425 "erlang-otp-linking-exception.json", "GPL with erlang-otp exception"
1426 )
1427
1428 def test_harbour(self):
1429 self._check("harbour-exception.json", "GPL with harbour exception")
1430
1431 def test_romic(self):
1432 self._check(
1433 "romic-exception.json", "AGPL-3 with romic exception", self._agpl_matcher
1434 )
1435
1436 def test_rsync_linking(self):
1437 self._check("rsync-linking-exception.json", "GPL with rsync-linking exception")
1438
1439 def test_stunnel(self):
1440 self._check("stunnel-exception.json", "GPL with stunnel exception")
1441
1442 def test_swi(self):
1443 self._check("SWI-exception.json", "GPL with SWI exception")
1444
1445 def test_texinfo(self):
1446 self._check("Texinfo-exception.json", "GPL-3 with Texinfo exception")
1447
1448 def test_ubdl(self):
1449 self._check("UBDL-exception.json", "GPL-2+ with UBDL exception")
1450
1451 def test_lgpl_qt_passes(self):
1452 self._check(
1453 "Nokia-Qt-exception-1.1.json",
1454 "LGPL-2.1 with Qt1.1 exception",
1455 self._lgpl_matcher,
1456 )
1457 self._check(
1458 "OCCT-exception-1.0.json",
1459 "LGPL-2.1 with OCCT-1 exception",
1460 self._lgpl_matcher,
1461 )
1462 self._check(
1463 "WxWindows-exception-3.1.json",
1464 "LGPL with WxWindows-3.1+ exception",
1465 self._lgpl_matcher,
1466 )
1467
1468 def test_cgal_linking(self):
1469 self._check(
1470 "CGAL-linking-exception.json",
1471 "LGPL with CGAL-linking exception",
1472 self._lgpl_matcher,
1473 )
1474
1475 def test_digia_qt(self):
1476 self._check(
1477 "Digia-Qt-LGPL-exception-1.1.json",
1478 "LGPL-2.1 with Digia-Qt exception",
1479 self._lgpl_matcher,
1480 )
1481
1482 def test_ocaml_lgpl(self):
1483 self._check(
1484 "OCaml-LGPL-linking-exception.json",
1485 "LGPL with OCaml-LGPL exception",
1486 self._lgpl_matcher,
1487 )
1488
1489 def test_qt_gpl(self):
1490 self._check(
1491 "Qt-GPL-exception-1.0.json",
1492 "LGPL with Qt-GPL-1 exception",
1493 self._lgpl_matcher,
1494 )
1495
1496 def test_qt_lgpl_1_1(self):
1497 self._check(
1498 "Qt-LGPL-exception-1.1.json",
1499 "LGPL-2.1 with Qt-LGPL-1.1 exception",
1500 self._lgpl_matcher,
1501 )
1502
1503 def test_qwt(self):
1504 self._check(
1505 "Qwt-exception-1.0.json", "LGPL with Qwt-1 exception", self._lgpl_matcher
1506 )
1507
1508 def test_simple_library_usage(self):
1509 self._check(
1510 "Simple-Library-Usage-exception.json",
1511 "LGPL-1+ with Simple-Library-Usage exception",
1512 self._lgpl_matcher,
1513 )
1514
1515 def test_libpri_openh323(self):
1516 self._check(
1517 "libpri-OpenH323-exception.json",
1518 "LGPL with libpri-OpenH323 exception",
1519 self._lgpl_matcher,
1520 )
1521
1522 def test_polyparse(self):
1523 self._check(
1524 "polyparse-exception.json",
1525 "LGPL with polyparse exception",
1526 self._lgpl_matcher,
1527 )
1528
1529 # --- OpenSSL/security family ---
1530
1531 def test_openssl_passes(self):
1532 self._check(
1533 "openvpn-openssl-exception.json", "GPL with openvpn-openssl exception"
1534 )
1535
1536 def test_bootloader(self):
1537 self._check("Bootloader-exception.json", "GPL with Bootloader exception")
1538
1539 def test_openssl_cryptsetup(self):
1540 self._check(
1541 "cryptsetup-OpenSSL-exception.json", "GPL with OpenSSL-cryptsetup exception"
1542 )
1543
1544 def test_openssl_kvirc(self):
1545 self._check("kvirc-openssl-exception.json", "GPL with OpenSSL-kvirc exception")
1546
1547 def test_rrdtool_floss(self):
1548 self._check(
1549 "RRDtool-FLOSS-exception-2.0.json", "GPL with RRDtool-FLOSS exception"
1550 )
1551
1552 def test_openssl_sqlitestudio(self):
1553 self._check(
1554 "sqlitestudio-OpenSSL-exception.json",
1555 "GPL with OpenSSL-sqlitestudio exception",
1556 )
1557
1558 def test_openssl_vsftpd(self):
1559 self._check(
1560 "vsftpd-openssl-exception.json", "GPL with OpenSSL-vsftpd exception"
1561 )
1562
1563 def test_openssl_x11vnc(self):
1564 self._check(
1565 "x11vnc-openssl-exception.json", "GPL with OpenSSL-x11vnc exception"
1566 )
1567
1568 # --- Apache/MIT/other base licences ---
1569
1570 def test_fmt(self):
1571 self._check("fmt-exception.json", "MIT with fmt exception", self._mit_matcher)
1572
1573 def test_gnome_examples(self):
1574 self._check(
1575 "GNOME-examples-exception.json",
1576 "CC-BY-SA with GNOME-examples exception",
1577 self._cc_by_sa_matcher,
1578 )
1579
1580 def test_openjdk_assembly(self):
1581 self._check(
1582 "OpenJDK-assembly-exception-1.0.json", "GPL with OpenJDK-assembly exception"
1583 )
1584
1585 def test_ps_or_pdf_font(self):
1586 self._check(
1587 "PS-or-PDF-font-exception-20170817.json",
1588 "AGPL-3 with PS-or-PDF-font exception",
1589 self._agpl_matcher,
1590 )
1591
1592 def test_qpl_inria(self):
1593 self._check(
1594 "QPL-1.0-INRIA-2004-exception.json",
1595 "QPL with QPL-INRIA-2004 exception",
1596 self._qpl_matcher,
1597 )
1598
1599 def test_sane(self):
1600 self._check("SANE-exception.json", "GPL with SANE exception")
1601
1602 def test_shl_2(self):
1603 self._check("SHL-2.0.json", "Apache with SHL-2 exception", self._apache_matcher)
1604
1605 def test_shl_2_1(self):
1606 self._check(
1607 "SHL-2.1.json", "Apache with SHL-2.1 exception", self._apache_matcher
1608 )
1609
1610 def test_swift(self):
1611 self._check(
1612 "Swift-exception.json", "Apache with Swift exception", self._apache_matcher
1613 )
1614
1615 def test_universal_foss(self):
1616 self._check(
1617 "Universal-FOSS-exception-1.0.json", "GPL with Universal-FOSS exception"
1618 )
1619
1620 # --- remaining / obscure ---
1621
1622 def test_asterisk(self):
1623 self._check("Asterisk-exception.json", "GPL with Asterisk exception")
1624
1625 def test_asterisk_linking(self):
1626 self._check(
1627 "Asterisk-linking-protocols-exception.json",
1628 "GPL with Asterisk-linking exception",
1629 )
1630
1631 # --- coverage gap sweep ---
1632
1633 def test_mxml(self):
1634 self._check(
1635 "mxml-exception.json", "Apache with mxml exception", self._apache_matcher
1636 )
1637
1638 def test_llvm(self):
1639 self._check(
1640 "LLVM-exception.json", "Apache with LLVM exception", self._apache_matcher
1641 )
1642
1643 def test_pcre2(self):
1644 self._check(
1645 "PCRE2-exception.json", "BSD with PCRE2 exception", self._bsd_matcher
1646 )
1647
1648 def test_lgpl3_linking(self):
1649 self._check(
1650 "LGPL-3.0-linking-exception.json",
1651 "LGPL-3 with LGPL-3-linking exception",
1652 self._lgpl_matcher,
1653 )
1654
1655 def test_llgpl(self):
1656 self._check("LLGPL.json", "LGPL-2.1 with LLGPL exception", self._lgpl_matcher)
1657
1658 def test_kicad_libraries(self):
1659 self._check(
1660 "KiCad-libraries-exception.json",
1661 "CC-BY-SA with KiCad-libraries exception",
1662 self._cc_by_sa_matcher,
1663 )
1664
1665
1666 if __name__ == "__main__":
1667 unittest.main()