From patchwork Thu Aug 18 20:30:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Tunnicliffe X-Patchwork-Id: 3520 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2476723F22 for ; Thu, 18 Aug 2011 20:30:20 +0000 (UTC) Received: from mail-ew0-f52.google.com (mail-ew0-f52.google.com [209.85.215.52]) by fiordland.canonical.com (Postfix) with ESMTP id 0EC81A1887C for ; Thu, 18 Aug 2011 20:30:20 +0000 (UTC) Received: by ewy28 with SMTP id 28so1269984ewy.11 for ; Thu, 18 Aug 2011 13:30:19 -0700 (PDT) Received: by 10.213.14.67 with SMTP id f3mr1960826eba.56.1313699419735; Thu, 18 Aug 2011 13:30:19 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.213.102.5 with SMTP id e5cs96408ebo; Thu, 18 Aug 2011 13:30:19 -0700 (PDT) Received: by 10.216.186.21 with SMTP id v21mr5748918wem.21.1313699418184; Thu, 18 Aug 2011 13:30:18 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id p63si1994654weq.54.2011.08.18.13.30.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 18 Aug 2011 13:30:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Qu9EH-00052y-Lc for ; Thu, 18 Aug 2011 20:30:17 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 9B99EE1590 for ; Thu, 18 Aug 2011 20:30:17 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 412 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 412: Fixes three problems shown by unit tests: Message-Id: <20110818203017.16186.43569.launchpad@ackee.canonical.com> Date: Thu, 18 Aug 2011 20:30:17 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13697"; Instance="initZopeless config overlay" X-Launchpad-Hash: f79cac6324381a71e3ec748dd9d93ea543073f84 Merge authors: James Tunnicliffe (dooferlad) Related merge proposals: https://code.launchpad.net/~dooferlad/linaro-image-tools/unit_test_fixes/+merge/72062 proposed by: James Tunnicliffe (dooferlad) review: Approve - James Westby (james-w) ------------------------------------------------------------ revno: 412 [merge] committer: James Tunnicliffe branch nick: linaro-image-tools timestamp: Thu 2011-08-18 21:29:15 +0100 message: Fixes three problems shown by unit tests: * Assert always runs - changed to raise AssertionError * Updated test_pyflakes.py so the "redefinition of unused CommandNotFound" error is ignored again * Test test_verify_files now passes (NamedTemporaryFile mocked to be predicatable) modified: linaro_image_tools/fetch_image.py linaro_image_tools/tests/test_pyflakes.py linaro_image_tools/tests/test_utils.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_image_tools/fetch_image.py' --- linaro_image_tools/fetch_image.py 2011-08-18 14:58:29 +0000 +++ linaro_image_tools/fetch_image.py 2011-08-18 16:00:26 +0000 @@ -1476,8 +1476,9 @@ ("platform", args['platform'])]) else: - assert(0, "Unexpected args['release_or_snapshot']: {0}".format( - args['release_or_snapshot'])) + message = "Unexpected args['release_or_snapshot']: {0}".format( + args['release_or_snapshot']) + raise AssertionError(message) if(not image_url): # If didn't get an image URL set up something so the return line === modified file 'linaro_image_tools/tests/test_pyflakes.py' --- linaro_image_tools/tests/test_pyflakes.py 2011-07-28 10:44:05 +0000 +++ linaro_image_tools/tests/test_pyflakes.py 2011-08-18 16:00:26 +0000 @@ -29,8 +29,8 @@ (stdout, stderr) = proc.communicate() stdout = stdout.splitlines() stdout.sort() - expected = ["./linaro_image_tools/utils.py:29: redefinition of " - "unused 'CommandNotFound' from line 27" ] + expected = ["./linaro_image_tools/utils.py:30: redefinition of " + "unused 'CommandNotFound' from line 28" ] self.assertEquals(expected, stdout) self.assertEquals('', stderr) === modified file 'linaro_image_tools/tests/test_utils.py' --- linaro_image_tools/tests/test_utils.py 2011-08-15 11:09:36 +0000 +++ linaro_image_tools/tests/test_utils.py 2011-08-18 16:00:26 +0000 @@ -22,6 +22,7 @@ import subprocess import sys import logging +import tempfile from linaro_image_tools import cmd_runner, utils from linaro_image_tools.testing import TestCaseWithFixtures @@ -91,14 +92,25 @@ TestVerifyFileIntegrity.filenames_in_shafile) + ': OK\n' raise cmd_runner.SubcommandNonZeroReturnValue([], 1, stdout, None) + class FakeTempFile(): + name = "/tmp/1" + + def close(self): + pass + + def read(self): + return "" def test_verify_files(self): fixture = self.useFixture(MockCmdRunnerPopenFixture()) + self.useFixture(MockSomethingFixture(tempfile, 'NamedTemporaryFile', + self.FakeTempFile)) hash_filename = "dummy-file.txt" signature_filename = hash_filename + ".asc" verify_file_integrity([signature_filename]) self.assertEqual( - ['gpg --verify %s' % signature_filename, + ['gpg --status-file=%s --verify %s' % (self.FakeTempFile.name, + signature_filename), 'sha1sum -c %s' % hash_filename], fixture.mock.commands_executed)