From patchwork Fri Dec 20 11:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 54458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BB34E77198 for ; Fri, 20 Dec 2024 11:26:41 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.106]) by mx.groups.io with SMTP id smtpd.web11.149743.1734693991344736713 for ; Fri, 20 Dec 2024 03:26:36 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@weidmueller.com header.s=selector2 header.b=5a2KgGS2; spf=pass (domain: weidmueller.com, ip: 40.107.22.106, mailfrom: stefan.herbrechtsmeier-oss@weidmueller.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MO9FckC4/+pjvSl85FXCvNz8zxqy9GwgNS1P7E3RRBAgva7AHCR5Jy2QJyvpFe5Oss12H3nzSTs3E3+93XoUApuYucvu3DabJstoPsQuk8Yy2rDJTsqzn/JViFbs7LoOe74Q+qZBb2EPsRsRu/s1dn6PHWJkOoZ8kZTmwraD7qNiWNjpUYmqFsB3wyUPpeCj/MME1uxxwyj0VvavZK5xjeWhNwIsFdsyKE4LzFIfaobnp+5ZYLye746OTUxziaIXSoZ/13aefrnaMCwOp8xBVMeJPBjCXAHcMAK0tYkIPe5iyWu3SXLdrz/qoRDsWDrdJLRYLQO+tCs9pXft+uWRPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CP6PRAT6tlYMnq9DSnjr6qPmKll6BATeTNlR+i/5Rnc=; b=VG5eNNUX8/dXRUEDorGOI8LzTIy6Yi4crClecA9xIyKIPbb9KpRRJz1ZMm+9w+Rcy6SFAId7b2Q2u2XrCcZIa810exPEMamaLSyUTGwL0rWFDS1oxqOWF4BsPcgCZ8ASK3qZHev0q7K3bq3074gk5pIIcOjmpveHoiwmLz12JL1e5LLxBSB0MsutKnLzHN1kr1Np8yXsoX90jdVbkpwiUFw+XHQrm0DJSC+a0g87F5mUBY20qvieG06AgpRuwjD6eYjDs0xlq0o2zqkzLODWKQhAg+DaRxug0fWIUwUPHjiZC4r/H7N+nntxGiw10URB7RyU+f0m9tRqep/PxjcuhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CP6PRAT6tlYMnq9DSnjr6qPmKll6BATeTNlR+i/5Rnc=; b=5a2KgGS2yCIIi34IhlL2817a2MP40dPaYpHe1hNUY4/h+gP+duKnbXCK6sYE5M96J/IhUWjZ6c7M34UJ1sv2AQ9l5Qy9gBSfMRyrVqTvOr1W/gTLxdBGYVdXRFjgNAIu30WwsWbaQKLaBiQ3mm/FmhWTxQpgu90bAG7CKq8Wb+M4EEvMnZo9cXJxHLKxHIFdNkEmgSZQE3bjSL6fnOacLdzjNTviD3XcXXbanmrc+63CZm3V/XUVsDP1MSy6qI8l/EO0ovywiJiKMNdvqGYPFRuhlAcImpfche+jQBE8/uqsJ2WhcJtT+CeyFn90lH6VoatCdJQ7HeRASkuGsGXDVw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by DU0PR08MB8256.eurprd08.prod.outlook.com (2603:10a6:10:410::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 11:26:28 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::3b1:b329:1ed9:dad4]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::3b1:b329:1ed9:dad4%3]) with mapi id 15.20.8272.013; Fri, 20 Dec 2024 11:26:28 +0000 From: Stefan Herbrechtsmeier To: bitbake-devel@lists.openembedded.org CC: Stefan Herbrechtsmeier Subject: [RFC PATCH 11/21] tests: fetch: adapt style in npm(sw) class Date: Fri, 20 Dec 2024 12:26:02 +0100 Message-ID: <20241220112613.22647-12-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241220112613.22647-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20241220112613.22647-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: FR0P281CA0106.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::7) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR08MB6969:EE_|DU0PR08MB8256:EE_ X-MS-Office365-Filtering-Correlation-Id: e76333fe-02b8-4f37-5e14-08dd20e924f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: BrulRto5BH+XqfiYhocXcdWli1bp9ch1lKuMRhENo/c4Yh+goYSLPKBkrfIOXvui6lGZhlygFjkg9PXjskegqUVXxKDSQeTo9SJ+Auwi1xLhJ+vGuE/l1bOtHKKUoOp+ClncG1/s4l/CSZ4eC3reH+c8YqU17BdKD67WTfXuYUSLU7IRn/XOPC0qedotWE/NXzirdPrd9vs86EutnAsz58f2qy19tZU9lAP3w+TCKqZuQx0ee9IxcfrK2KoOaOqNul1E0UkM0Q/JSEOveHECYzoUWp+ZU74vV6lAbtb8CzG4I4nZrPwhJr5vPD3WTWTu1haT+V1D01qFLc0kY0ew8wkp6Sjrte89KW6zWy7qe+Rf7RFLBMJcYuc6ypstifScU8M6F1KYQHuFg7baFkYtdXOkqOoa1L4oSBY7WH22MnA35oUh5b/4oSdRZDIwNGIOdAOoz0TMcN/OHvwDef9hmZgT/NCZutotR2YOv5bwZd6+Ke7TZnEZhSqAFCiebVGPji7SDAu+V1cX4xdJkexf3W3we94JvNglcxuskup99vJ/jofi/HZ8Kev/ajUTFlkP5VkMeip3rv9rjsxGKDbKfXeSHc1JNx4R74ufYPe6YcvrbQhdHcPJfDiwjLX+Ng6vH20FAbxw/zPBKXThnElE5WvZ0e6Jjk3QldRhq7r7sgjxD2pqECINCECbKqIpZdGOLZZoaMfOWELQVSofNUbkGKNNLZesv+brULC8wTbFh0jIvMoDwL5MBl00IlaBRR3CBgPQJOOAmAg5QT2HhyEPUCD2ZFPND8NtrzH83PJYWkm5OBqC/V0Ydr6UwvMdTaR07AAvs/AvQHfBAnSESD/MYPPORIz7y9rORSpklaEiD2g3rJQPr7y5Wpwy2RPsqbMgrXaK6SB6GSb3gLKFRbK65o+DyBqTeXPWX1LUVJ7KqbkXxrumzswZlDdP3mTVGRuQYekqtzwvu9kuMLpEYlhVIbjNxChI6r3cI/kkWBpiHkP89xTqBqvPWlVSpY2SwHvbMBqBLI+e8nTsTct5pxL9n3/jGokrR3J1KkH94v6KNVS2NC0jwkNwB/TSWcs+JxtqpizebP7Wa5sQrw6wX424BAeH7hDSxFFNDxnGz3ztfG/ywhO6RvBkwnBpbQD3szIutdMwniSyIgaqESFs58slfoCYW0ogDRn3rt5T3CN47TmKWCfDMca1z/iPY3cIcAK2hFXuB+tkScxok4RNktlXK652VqISw/5RRbJpNZtzlVgvhGzbPdkzv064L4ZdG1tD5cxHF9bqcISQxOFOiXsid0EjZ7nsA+o13RdlAyq3FdIoCmn2fGfmVTPbAMdcrx8nxbrpiv/Brav15QqWJSJKO7utZTv/onAFROIGMKOmGc36OEYrw0vd+QMdx7UY7btJtafdaertXndMNQX7DZ9jIQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6969.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(1800799024)(376014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TOr71IKYxZU8n0nlkIMK+DN8XlMu8LCxqKCVIXpahF9OBjGZGXrMRgJwoftb1ovPbe9xLlQYBlrFemwbEE3YJZfDy/ktTq3qULKuMB+XwaRva+hQDBzQz/bQGLKC2/rpm9LPrqv5Cws5TZkySo8wsJXB+NUDBr35oodhohM4z6RgX03QoesOkm4EnA+kdYjK+T0eaYAHvSd6WMI/2N7SbLTcZ67JrejC8CsH/1pfB1cyOt48QCuhzbRYHEWY1j+uz0gfZae90HPSIiDucYtNuUdo+O1w/FfO46BRn4r1NuGLPANBDKbrPzx5NbLTXcwa+ZDKxHGUGVCTPgNkkKeFrapDk46FsSDGlhGeXoJkfSYtTgpFX90Q5pTVQLran5hk9pX8NBqr7zV1rtGNwgPERYzjKRZzutEUTt19z8AvN+Fgc90vUAlVH/7nr1lVUGVb96AZHc6w46TeTJGozcELRmH5XwTbTMEsDzYOOeCdiDeEsrNeaH4HHYO7ELKdxMa14+QmFFB8VJAaptJpDBpW0fg+1C/hvIu2gg/D5hRIzcXHQVvR4SSa2WVe3GXoQIMb0oTDiM05vuUqm9IDj3QigCcBYfndzsj7Rh7BhmNwimR7byVTWXAsIOLcw4p1tymEGY27IqRe3cTf/4bRtlO1SstGuJSCQLpZCDbGKFupZ84t7pu7WBUA/Pg6LuCRdFeBHS5IYRAyo3lZodBsh0jBo/nF2m8aTfKl+K8Y5H70ZT5WDeWJvkjywgEldpGIQ7AukZG5nki5e8bDuHpP91z8OXsUawLe29sovvKtD9eTLU/T+aSNeWuzmadLFwNt6YfjZlvFM9eNQdVMRysv/JWykJybID1UwJNUgUqU4JGzd3jEPlRTSRgxh7Zt/SR4dE9xjwuH7mJ+PgjoxPsmcuAkajJgd0R06PxxpXQkI8oK0S/1yw9sKFTkQeR3sfd+0goRyo08D7J5DQBxYrkXxiXQHnFxM9cOTFbM97g2h7RIm1Z/quTw8dQBxQV1OkuZdi7XRlYA9W9DGU8U3KJ5AbgliMojzi5ByfrDO3rU2D8Ojn5eTeIsFA/K87KaMbMWtQaWNIjnoeDja/q3I607QzpJRJy82HfFqBHigHsFTtsHxp+aLv+cKlIOLICGbadHOASBXS2T/2uxi59fdhDi7y8egJqLRy81taJXJl/8sFpKm4Is2HYcfpY6Gsh1d9xzJvQvk4kc6WvP7b+B13skunwLSQfetcJKuvcnmgo/fXpTgCpMrFVB4SQsjeVGtGlCFTP3EaUk0Q5pJETA2fbb5Xk1WfbLLwQ/sup7eHNaBX8m/uKiBAqRfELJByXogICMhzL0uORVVIjTWjHHau0ZKbmzIwZEqPLADaLe+n0neGFGtAs6POIUs0/qaWiO5bshTDVn6fC760aAWNb7zO8xaAPRsVZPa7JDUxR8My/K5y/xR/ahSyizl1/HpQ/isDOMwhOSnlJtMpLqjU7kHwLexeGYJMxndg01iiKmPxEkloDSHuvIB0Gw5pZ9Ssfy09wjOGX2DZTqodcczscuz77MKBEHWRauBvRvnVe/aQe+RdXD6qfePFxqamitIe+GAV6b4ydYCAGhWmoUvAgV6XE9lHrGLA== X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: e76333fe-02b8-4f37-5e14-08dd20e924f7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 11:26:27.7618 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7TinhaW4g8wcAujuxZh44lt/LmiTPcBTEOHj/8M+N/hg1c8SL5o5jNH6JMrTfHXup3BhP+BGFMdrlSIrgYe3ug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8256 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 20 Dec 2024 11:26:41 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/16935 From: Stefan Herbrechtsmeier Signed-off-by: Stefan Herbrechtsmeier --- lib/bb/tests/fetch.py | 348 +++++++++++++++++++++--------------------- 1 file changed, 174 insertions(+), 174 deletions(-) diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index 6b8e3e060..934b96cac 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -2620,47 +2620,47 @@ class CrateTest(FetcherTest): class NPMTest(FetcherTest): def skipIfNoNpm(): import shutil - if not shutil.which('npm'): - return unittest.skip('npm not installed') + if not shutil.which("npm"): + return unittest.skip("npm not installed") return lambda f: f @skipIfNoNpm() @skipIfNoNetwork() def test_npm(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0"] fetcher = bb.fetch.Fetch(urls, self.d) ud = fetcher.ud[fetcher.urls[0]] fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) - self.assertTrue(os.path.exists(ud.localpath + '.done')) + self.assertTrue(os.path.exists(ud.localpath + ".done")) self.assertTrue(os.path.exists(ud.resolvefile)) fetcher.unpack(self.unpackdir) - unpackdir = os.path.join(self.unpackdir, 'npm') - self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json'))) + unpackdir = os.path.join(self.unpackdir, "npm") + self.assertTrue(os.path.exists(os.path.join(unpackdir, "package.json"))) @skipIfNoNpm() @skipIfNoNetwork() def test_npm_bad_checksum(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0"] # Fetch once to get a tarball fetcher = bb.fetch.Fetch(urls, self.d) ud = fetcher.ud[fetcher.urls[0]] fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) # Modify the tarball - bad = b'bad checksum' - with open(ud.localpath, 'wb') as f: + bad = b"bad checksum" + with open(ud.localpath, "wb") as f: f.write(bad) # Verify that the tarball is fetched again fetcher.download() badsum = hashlib.sha512(bad).hexdigest() - self.assertTrue(os.path.exists(ud.localpath + '_bad-checksum_' + badsum)) + self.assertTrue(os.path.exists(ud.localpath + "_bad-checksum_" + badsum)) self.assertTrue(os.path.exists(ud.localpath)) @skipIfNoNpm() @skipIfNoNetwork() def test_npm_premirrors(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0"] # Fetch once to get a tarball fetcher = bb.fetch.Fetch(urls, self.d) ud = fetcher.ud[fetcher.urls[0]] @@ -2668,17 +2668,17 @@ class NPMTest(FetcherTest): self.assertTrue(os.path.exists(ud.localpath)) # Setup the mirror by renaming the download directory - mirrordir = os.path.join(self.tempdir, 'mirror') + mirrordir = os.path.join(self.tempdir, "mirror") bb.utils.rename(self.dldir, mirrordir) os.mkdir(self.dldir) # Configure the premirror to be used - self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/npm2' % mirrordir) - self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') + self.d.setVar("PREMIRRORS", "https?$://.*/.* file://%s/npm2" % mirrordir) + self.d.setVar("BB_FETCH_PREMIRRORONLY", "1") # Fetch again self.assertFalse(os.path.exists(ud.localpath)) - # The npm fetcher doesn't handle that the .resolved file disappears + # The npm fetcher doesn"t handle that the .resolved file disappears # while the fetcher object exists, which it does when we rename the # download directory to "mirror" above. Thus we need a new fetcher to go # with the now empty download directory. @@ -2690,19 +2690,19 @@ class NPMTest(FetcherTest): @skipIfNoNpm() @skipIfNoNetwork() def test_npm_premirrors_with_specified_filename(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0"] # Fetch once to get a tarball fetcher = bb.fetch.Fetch(urls, self.d) ud = fetcher.ud[fetcher.urls[0]] fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) # Setup the mirror - mirrordir = os.path.join(self.tempdir, 'mirror') + mirrordir = os.path.join(self.tempdir, "mirror") bb.utils.mkdirhier(mirrordir) mirrorfilename = os.path.join(mirrordir, os.path.basename(ud.localpath)) os.replace(ud.localpath, mirrorfilename) - self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s' % mirrorfilename) - self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') + self.d.setVar("PREMIRRORS", "https?$://.*/.* file://%s" % mirrorfilename) + self.d.setVar("BB_FETCH_PREMIRRORONLY", "1") # Fetch again self.assertFalse(os.path.exists(ud.localpath)) fetcher.download() @@ -2712,22 +2712,22 @@ class NPMTest(FetcherTest): @skipIfNoNetwork() def test_npm_mirrors(self): # Fetch once to get a tarball - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0"] fetcher = bb.fetch.Fetch(urls, self.d) ud = fetcher.ud[fetcher.urls[0]] fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) # Setup the mirror - mirrordir = os.path.join(self.tempdir, 'mirror') + mirrordir = os.path.join(self.tempdir, "mirror") bb.utils.mkdirhier(mirrordir) os.replace(ud.localpath, os.path.join(mirrordir, os.path.basename(ud.localpath))) - self.d.setVar('MIRRORS', 'https?$://.*/.* file://%s/' % mirrordir) + self.d.setVar("MIRRORS", "https?$://.*/.* file://%s/" % mirrordir) # Update the resolved url to an invalid url - with open(ud.resolvefile, 'r') as f: + with open(ud.resolvefile, "r") as f: url = f.read() uri = URI(url) - uri.path = '/invalid' - with open(ud.resolvefile, 'w') as f: + uri.path = "/invalid" + with open(ud.resolvefile, "w") as f: f.write(str(uri)) # Fetch again self.assertFalse(os.path.exists(ud.localpath)) @@ -2737,17 +2737,17 @@ class NPMTest(FetcherTest): @skipIfNoNpm() @skipIfNoNetwork() def test_npm_destsuffix_downloadfilename(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0;destsuffix=foo/bar;downloadfilename=foo-bar.tgz'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0;destsuffix=foo/bar;downloadfilename=foo-bar.tgz"] fetcher = bb.fetch.Fetch(urls, self.d) fetcher.download() - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'foo-bar.tgz'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "npm2/foo-bar.tgz"))) fetcher.unpack(self.unpackdir) - unpackdir = os.path.join(self.unpackdir, 'foo', 'bar') - self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json'))) + unpackdir = os.path.join(self.unpackdir, "foo", "bar") + self.assertTrue(os.path.exists(os.path.join(unpackdir, "package.json"))) def test_npm_no_network_no_tarball(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'] - self.d.setVar('BB_NO_NETWORK', '1') + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0"] + self.d.setVar("BB_NO_NETWORK", "1") fetcher = bb.fetch.Fetch(urls, self.d) with self.assertRaises(bb.fetch2.NetworkAccess): fetcher.download() @@ -2755,42 +2755,42 @@ class NPMTest(FetcherTest): @skipIfNoNpm() @skipIfNoNetwork() def test_npm_no_network_with_tarball(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0"] # Fetch once to get a tarball fetcher = bb.fetch.Fetch(urls, self.d) fetcher.download() # Disable network access - self.d.setVar('BB_NO_NETWORK', '1') + self.d.setVar("BB_NO_NETWORK", "1") # Fetch again fetcher.download() fetcher.unpack(self.unpackdir) - unpackdir = os.path.join(self.unpackdir, 'npm') - self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json'))) + unpackdir = os.path.join(self.unpackdir, "npm") + self.assertTrue(os.path.exists(os.path.join(unpackdir, "package.json"))) @skipIfNoNpm() @skipIfNoNetwork() def test_npm_registry_alternate(self): - urls = ['npm://skimdb.npmjs.com;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://skimdb.npmjs.com;package=@savoirfairelinux/node-server-example;version=1.0.0"] fetcher = bb.fetch.Fetch(urls, self.d) fetcher.download() fetcher.unpack(self.unpackdir) - unpackdir = os.path.join(self.unpackdir, 'npm') - self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json'))) + unpackdir = os.path.join(self.unpackdir, "npm") + self.assertTrue(os.path.exists(os.path.join(unpackdir, "package.json"))) @skipIfNoNpm() @skipIfNoNetwork() def test_npm_version_latest(self): - url = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=latest'] + url = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=latest"] fetcher = bb.fetch.Fetch(urls, self.d) fetcher.download() fetcher.unpack(self.unpackdir) - unpackdir = os.path.join(self.unpackdir, 'npm') - self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json'))) + unpackdir = os.path.join(self.unpackdir, "npm") + self.assertTrue(os.path.exists(os.path.join(unpackdir, "package.json"))) @skipIfNoNpm() @skipIfNoNetwork() def test_npm_registry_invalid(self): - urls = ['npm://registry.invalid.org;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://registry.invalid.org;package=@savoirfairelinux/node-server-example;version=1.0.0"] fetcher = bb.fetch.Fetch(urls, self.d) with self.assertRaises(bb.fetch2.FetchError): fetcher.download() @@ -2798,7 +2798,7 @@ class NPMTest(FetcherTest): @skipIfNoNpm() @skipIfNoNetwork() def test_npm_package_invalid(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/invalid;version=1.0.0'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/invalid;version=1.0.0"] fetcher = bb.fetch.Fetch(urls, self.d) with self.assertRaises(bb.fetch2.FetchError): fetcher.download() @@ -2806,145 +2806,145 @@ class NPMTest(FetcherTest): @skipIfNoNpm() @skipIfNoNetwork() def test_npm_version_invalid(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=invalid'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=invalid"] with self.assertRaises(bb.fetch2.ParameterError): fetcher = bb.fetch.Fetch(urls, self.d) @skipIfNoNpm() @skipIfNoNetwork() def test_npm_registry_none(self): - urls = ['npm://;package=@savoirfairelinux/node-server-example;version=1.0.0'] + urls = ["npm://;package=@savoirfairelinux/node-server-example;version=1.0.0"] with self.assertRaises(bb.fetch2.MalformedUrl): fetcher = bb.fetch.Fetch(urls, self.d) @skipIfNoNpm() @skipIfNoNetwork() def test_npm_package_none(self): - urls = ['npm://registry.npmjs.org;version=1.0.0'] + urls = ["npm://registry.npmjs.org;version=1.0.0"] with self.assertRaises(bb.fetch2.MissingParameterError): fetcher = bb.fetch.Fetch(urls, self.d) @skipIfNoNpm() @skipIfNoNetwork() def test_npm_version_none(self): - urls = ['npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example'] + urls = ["npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example"] with self.assertRaises(bb.fetch2.MissingParameterError): fetcher = bb.fetch.Fetch(urls, self.d) def create_shrinkwrap_file(self, data): import json - datadir = os.path.join(self.tempdir, 'data') - swfile = os.path.join(datadir, 'npm-shrinkwrap.json') + datadir = os.path.join(self.tempdir, "data") + swfile = os.path.join(datadir, "npm-shrinkwrap.json") bb.utils.mkdirhier(datadir) - with open(swfile, 'w') as f: + with open(swfile, "w") as f: json.dump(data, f) return swfile @skipIfNoNetwork() def test_npmsw(self): swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=', - 'dependencies': { - 'content-type': "1.0.4" + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", + "dependencies": { + "content-type": "1.0.4" } }, - 'node_modules/array-flatten/node_modules/content-type': { - 'version': '1.0.4', - 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz', - 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==', - 'dependencies': { - 'cookie': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09' + "node_modules/array-flatten/node_modules/content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "dependencies": { + "cookie": "git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09" } }, - 'node_modules/array-flatten/node_modules/content-type/node_modules/cookie': { - 'resolved': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09' + "node_modules/array-flatten/node_modules/content-type/node_modules/cookie": { + "resolved": "git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz'))) - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz'))) - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'github.com.jshttp.cookie.git'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "npm2/array-flatten-1.1.1.tgz"))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "npm2/content-type-1.0.4.tgz"))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "git2/github.com.jshttp.cookie.git"))) fetcher.unpack(self.unpackdir) - self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'npm-shrinkwrap.json'))) - self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'node_modules', 'array-flatten', 'package.json'))) - self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'node_modules', 'array-flatten', 'node_modules', 'content-type', 'package.json'))) - self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'node_modules', 'array-flatten', 'node_modules', 'content-type', 'node_modules', 'cookie', 'package.json'))) + self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "npm-shrinkwrap.json"))) + self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "node_modules/array-flatten/package.json"))) + self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "node_modules/array-flatten/node_modules/content-type/package.json"))) + self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "node_modules/array-flatten/node_modules/content-type/node_modules/cookie/package.json"))) @skipIfNoNetwork() def test_npmsw_git(self): swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/cookie': { - 'resolved': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09' + "packages": { + "node_modules/cookie": { + "resolved": "git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'github.com.jshttp.cookie.git'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "git2/github.com.jshttp.cookie.git"))) @skipIfNoNetwork() def test_npmsw_dev(self): swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, - 'node_modules/content-type': { - 'version': '1.0.4', - 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz', - 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==', - 'dev': True + "node_modules/content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "dev": True } } }) # Fetch with dev disabled - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz'))) - self.assertFalse(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "npm2/array-flatten-1.1.1.tgz"))) + self.assertFalse(os.path.exists(os.path.join(self.dldir, "npm2/content-type-1.0.4.tgz"))) # Fetch with dev enabled - fetcher = bb.fetch.Fetch(['npmsw://' + swfile + ';dev=1'], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile + ";dev=1"], self.d) fetcher.download() - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz'))) - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "npm2/array-flatten-1.1.1.tgz"))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "npm2/content-type-1.0.4.tgz"))) @skipIfNoNetwork() def test_npmsw_destsuffix(self): swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile + ';destsuffix=foo/bar'], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile + ";destsuffix=foo/bar"], self.d) fetcher.download() fetcher.unpack(self.unpackdir) - self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'foo', 'bar', 'node_modules', 'array-flatten', 'package.json'))) + self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "foo/bar/node_modules/array-flatten/package.json"))) def test_npmsw_no_network_no_tarball(self): swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" } } }) - self.d.setVar('BB_NO_NETWORK', '1') - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + self.d.setVar("BB_NO_NETWORK", "1") + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) with self.assertRaises(bb.fetch2.NetworkAccess): fetcher.download() @@ -2952,112 +2952,112 @@ class NPMTest(FetcherTest): @skipIfNoNetwork() def test_npmsw_no_network_with_tarball(self): # Fetch once to get a tarball - fetcher = bb.fetch.Fetch(['npm://registry.npmjs.org;package=array-flatten;version=1.1.1'], self.d) + fetcher = bb.fetch.Fetch(["npm://registry.npmjs.org;package=array-flatten;version=1.1.1"], self.d) fetcher.download() # Disable network access - self.d.setVar('BB_NO_NETWORK', '1') + self.d.setVar("BB_NO_NETWORK", "1") # Fetch again swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() fetcher.unpack(self.unpackdir) - self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'node_modules', 'array-flatten', 'package.json'))) + self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "node_modules/array-flatten/package.json"))) @skipIfNoNetwork() def test_npmsw_npm_reusability(self): # Fetch once with npmsw swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() # Disable network access - self.d.setVar('BB_NO_NETWORK', '1') + self.d.setVar("BB_NO_NETWORK", "1") # Fetch again with npm - fetcher = bb.fetch.Fetch(['npm://registry.npmjs.org;package=array-flatten;version=1.1.1'], self.d) + fetcher = bb.fetch.Fetch(["npm://registry.npmjs.org;package=array-flatten;version=1.1.1"], self.d) fetcher.download() fetcher.unpack(self.unpackdir) - self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'npm', 'package.json'))) + self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "npm/package.json"))) @skipIfNoNetwork() def test_npmsw_bad_checksum(self): # Try to fetch with bad checksum swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-gfNEp2hqgLTFKT6P3AsBYMgsBqg=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-gfNEp2hqgLTFKT6P3AsBYMgsBqg=" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) with self.assertRaises(bb.fetch2.FetchError): fetcher.download() # Fetch correctly to get a tarball swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() - localpath = os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz') + localpath = os.path.join(self.dldir, "npm2/array-flatten-1.1.1.tgz") self.assertTrue(os.path.exists(localpath)) # Modify the tarball - bad = b'bad checksum' - with open(localpath, 'wb') as f: + bad = b"bad checksum" + with open(localpath, "wb") as f: f.write(bad) # Verify that the tarball is fetched again fetcher.download() badsum = hashlib.sha1(bad).hexdigest() - self.assertTrue(os.path.exists(localpath + '_bad-checksum_' + badsum)) + self.assertTrue(os.path.exists(localpath + "_bad-checksum_" + badsum)) self.assertTrue(os.path.exists(localpath)) @skipIfNoNpm() @skipIfNoNetwork() def test_npmsw_premirrors(self): # Fetch once to get a tarball - fetcher = bb.fetch.Fetch(['npm://registry.npmjs.org;package=array-flatten;version=1.1.1'], self.d) + fetcher = bb.fetch.Fetch(["npm://registry.npmjs.org;package=array-flatten;version=1.1.1"], self.d) ud = fetcher.ud[fetcher.urls[0]] fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) # Setup the mirror - mirrordir = os.path.join(self.tempdir, 'mirror') + mirrordir = os.path.join(self.tempdir, "mirror") bb.utils.mkdirhier(mirrordir) os.replace(ud.localpath, os.path.join(mirrordir, os.path.basename(ud.localpath))) - self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/' % mirrordir) - self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') + self.d.setVar("PREMIRRORS", "https?$://.*/.* file://%s/" % mirrordir) + self.d.setVar("BB_FETCH_PREMIRRORONLY", "1") # Fetch again self.assertFalse(os.path.exists(ud.localpath)) swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) @@ -3065,51 +3065,51 @@ class NPMTest(FetcherTest): @skipIfNoNetwork() def test_npmsw_mirrors(self): # Fetch once to get a tarball - fetcher = bb.fetch.Fetch(['npm://registry.npmjs.org;package=array-flatten;version=1.1.1'], self.d) + fetcher = bb.fetch.Fetch(["npm://registry.npmjs.org;package=array-flatten;version=1.1.1"], self.d) ud = fetcher.ud[fetcher.urls[0]] fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) # Setup the mirror - mirrordir = os.path.join(self.tempdir, 'mirror') + mirrordir = os.path.join(self.tempdir, "mirror") bb.utils.mkdirhier(mirrordir) os.replace(ud.localpath, os.path.join(mirrordir, os.path.basename(ud.localpath))) - self.d.setVar('MIRRORS', 'https?$://.*/.* file://%s/' % mirrordir) + self.d.setVar("MIRRORS", "https?$://.*/.* file://%s/" % mirrordir) # Fetch again with invalid url self.assertFalse(os.path.exists(ud.localpath)) swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://invalid', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://invalid", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) @skipIfNoNetwork() def test_npmsw_bundled(self): swfile = self.create_shrinkwrap_file({ - 'packages': { - 'node_modules/array-flatten': { - 'version': '1.1.1', - 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', - 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + "packages": { + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, - 'node_modules/content-type': { - 'version': '1.0.4', - 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz', - 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==', - 'inBundle': True + "node_modules/content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "inBundle": True } } }) - fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher = bb.fetch.Fetch(["npmsw://" + swfile], self.d) fetcher.download() - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz'))) - self.assertFalse(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, "npm2/array-flatten-1.1.1.tgz"))) + self.assertFalse(os.path.exists(os.path.join(self.dldir, "npm2/content-type-1.0.4.tgz"))) class GitSharedTest(FetcherTest): def setUp(self):