Sat Jan 1 15:04:58 2022 UTC ()
url2pkg: test current behavior for PyPI downloads


(rillig)
diff -r1.34 -r1.35 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py

cvs diff -r1.34 -r1.35 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py 2022/01/01 14:04:11 1.34
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py 2022/01/01 15:04:58 1.35
@@ -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
3import pytest 3import pytest
4from url2pkg import * 4from url2pkg import *
5from textwrap import dedent 5from textwrap import dedent
6 6
7mkcvsid = '# $''NetBSD$' 7mkcvsid = '# $''NetBSD$'
8g: Globals 8g: Globals
9prev_dir = Path.cwd() 9prev_dir = Path.cwd()
10 10
11 11
12def setup_function(_): 12def 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
 603def 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
603def test_Generator_adjust_site_from_sites_mk__R(tmp_path: Path): 632def 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
614def test_Generator_adjust_site_other__malformed_URL(): 643def 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.