| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: url2pkg_test.py,v 1.34 2022/01/01 14:04:11 rillig Exp $ | | 1 | # $NetBSD: url2pkg_test.py,v 1.35 2022/01/01 15:04:58 rillig Exp $ |
2 | | | 2 | |
3 | import pytest | | 3 | import pytest |
4 | from url2pkg import * | | 4 | from url2pkg import * |
5 | from textwrap import dedent | | 5 | from textwrap import dedent |
6 | | | 6 | |
7 | mkcvsid = '# $''NetBSD$' | | 7 | mkcvsid = '# $''NetBSD$' |
8 | g: Globals | | 8 | g: Globals |
9 | prev_dir = Path.cwd() | | 9 | prev_dir = Path.cwd() |
10 | | | 10 | |
11 | | | 11 | |
12 | def setup_function(_): | | 12 | def setup_function(_): |
13 | global g | | 13 | global g |
14 | | | 14 | |
| @@ -590,26 +590,55 @@ def test_Generator_adjust_site_from_site | | | @@ -590,26 +590,55 @@ def test_Generator_adjust_site_from_site |
590 | 'CATEGORIES= pkgtools', | | 590 | 'CATEGORIES= pkgtools', |
591 | 'MASTER_SITES= ${MASTER_SITE_GNU:=cflow/}', | | 591 | 'MASTER_SITES= ${MASTER_SITE_GNU:=cflow/}', |
592 | '', | | 592 | '', |
593 | 'MAINTAINER= INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users@NetBSD.org', | | 593 | 'MAINTAINER= INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users@NetBSD.org', |
594 | 'HOMEPAGE= https://www.gnu.org/software/cflow/', | | 594 | 'HOMEPAGE= https://www.gnu.org/software/cflow/', |
595 | 'COMMENT= TODO: Short description of the package', | | 595 | 'COMMENT= TODO: Short description of the package', |
596 | '#LICENSE= # TODO: (see mk/license.mk)', | | 596 | '#LICENSE= # TODO: (see mk/license.mk)', |
597 | '', | | 597 | '', |
598 | '# url2pkg-marker (please do not remove this line.)', | | 598 | '# url2pkg-marker (please do not remove this line.)', |
599 | '.include "../../mk/bsd.pkg.mk"', | | 599 | '.include "../../mk/bsd.pkg.mk"', |
600 | ] | | 600 | ] |
601 | | | 601 | |
602 | | | 602 | |
| | | 603 | def test_Generator_adjust_site_from_sites_mk__PyPI(): |
| | | 604 | url = ('https://files.pythonhosted.org/' |
| | | 605 | + 'packages/da/8b/218264f5ce91df1ad27ce8021d51b747ef287627338fe05d170565358546/' |
| | | 606 | + 'apprise-0.9.6.tar.gz') |
| | | 607 | generator = Generator(url) |
| | | 608 | |
| | | 609 | lines = generator.generate_Makefile() |
| | | 610 | |
| | | 611 | assert detab(lines) == [ |
| | | 612 | mkcvsid, |
| | | 613 | '', |
| | | 614 | 'DISTNAME= apprise-0.9.6', |
| | | 615 | 'CATEGORIES= pkgtools', |
| | | 616 | # TODO: ${MASTER_SITE_PYPI:=a/apprise/} |
| | | 617 | 'MASTER_SITES= https://files.pythonhosted.org/packages/da/8b/' |
| | | 618 | + '218264f5ce91df1ad27ce8021d51b747ef287627338fe05d170565358546/', |
| | | 619 | '', |
| | | 620 | 'MAINTAINER= INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users@NetBSD.org', |
| | | 621 | # TODO: https://pypi.org/project/apprise/ |
| | | 622 | 'HOMEPAGE= https://files.pythonhosted.org/packages/da/8b/' |
| | | 623 | + '218264f5ce91df1ad27ce8021d51b747ef287627338fe05d170565358546/', |
| | | 624 | 'COMMENT= TODO: Short description of the package', |
| | | 625 | '#LICENSE= # TODO: (see mk/license.mk)', |
| | | 626 | '', |
| | | 627 | '# url2pkg-marker (please do not remove this line.)', |
| | | 628 | '.include "../../mk/bsd.pkg.mk"', |
| | | 629 | ] |
| | | 630 | |
| | | 631 | |
603 | def test_Generator_adjust_site_from_sites_mk__R(tmp_path: Path): | | 632 | def test_Generator_adjust_site_from_sites_mk__R(tmp_path: Path): |
604 | g.pkgdir = tmp_path | | 633 | g.pkgdir = tmp_path |
605 | url = 'http://cran.r-project.org/src/contrib/forecast_8.7.tar.gz' | | 634 | url = 'http://cran.r-project.org/src/contrib/forecast_8.7.tar.gz' |
606 | generator = Generator(url) | | 635 | generator = Generator(url) |
607 | | | 636 | |
608 | with pytest.raises(SystemExit, match='^url2pkg: to create R packages, use pkgtools/R2pkg instead$'): | | 637 | with pytest.raises(SystemExit, match='^url2pkg: to create R packages, use pkgtools/R2pkg instead$'): |
609 | generator.generate_Makefile() | | 638 | generator.generate_Makefile() |
610 | | | 639 | |
611 | assert list(tmp_path.glob('*')) == [] | | 640 | assert list(tmp_path.glob('*')) == [] |
612 | | | 641 | |
613 | | | 642 | |
614 | def test_Generator_adjust_site_other__malformed_URL(): | | 643 | def test_Generator_adjust_site_other__malformed_URL(): |
615 | # This error is supposed to be handled by the URL check in main. | | 644 | # This error is supposed to be handled by the URL check in main. |