From patchwork Thu Aug 18 09:29:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Tunnicliffe X-Patchwork-Id: 3502 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 954A223F41 for ; Thu, 18 Aug 2011 09:29:17 +0000 (UTC) Received: from mail-ey0-f170.google.com (mail-ey0-f170.google.com [209.85.215.170]) by fiordland.canonical.com (Postfix) with ESMTP id 8055FA18089 for ; Thu, 18 Aug 2011 09:29:17 +0000 (UTC) Received: by eyd10 with SMTP id 10so1424343eyd.29 for ; Thu, 18 Aug 2011 02:29:17 -0700 (PDT) Received: by 10.213.14.67 with SMTP id f3mr1625650eba.56.1313659756792; Thu, 18 Aug 2011 02:29:16 -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 e5cs63118ebo; Thu, 18 Aug 2011 02:29:16 -0700 (PDT) Received: by 10.227.19.132 with SMTP id a4mr1778209wbb.46.1313659755872; Thu, 18 Aug 2011 02:29:15 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id gd15si480738wbb.5.2011.08.18.02.29.15 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 18 Aug 2011 02:29:15 -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 1QtyuZ-0006nh-Da for ; Thu, 18 Aug 2011 09:29:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 51E98E0205 for ; Thu, 18 Aug 2011 09:29:15 +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: 409 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 409: Modifications that change the fetch image library unit tests to use local files, not downloaded o... Message-Id: <20110818092915.1732.43382.launchpad@ackee.canonical.com> Date: Thu, 18 Aug 2011 09:29:15 -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: 43eacad68987d1e0f4418ecd110e933a57713cea Merge authors: James Tunnicliffe (dooferlad) Related merge proposals: https://code.launchpad.net/~dooferlad/linaro-image-tools/fetch_image_unit_tests_use_local_files/+merge/71243 proposed by: James Tunnicliffe (dooferlad) review: Approve - James Westby (james-w) ------------------------------------------------------------ revno: 409 [merge] committer: James Tunnicliffe branch nick: linaro-image-tools timestamp: Thu 2011-08-18 10:28:12 +0100 message: Modifications that change the fetch image library unit tests to use local files, not downloaded ones. added: linaro_image_tools/tests/test_server_index.sqlite modified: linaro_image_tools/tests/test_fetch_image.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/tests/test_fetch_image.py' --- linaro_image_tools/tests/test_fetch_image.py 2011-07-26 15:40:32 +0000 +++ linaro_image_tools/tests/test_fetch_image.py 2011-08-17 13:18:37 +0000 @@ -16,28 +16,34 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . - -import wx -import unittest +import os +from linaro_image_tools.testing import TestCaseWithFixtures import re import linaro_image_tools.fetch_image as fetch_image -class TestURLLookupFunctions(unittest.TestCase): +class TestURLLookupFunctions(TestCaseWithFixtures): def setUp(self): + # We use local files for testing, so get paths sorted. + this_file = os.path.abspath(__file__) + this_dir = os.path.dirname(this_file) + yaml_file_location = os.path.join(this_dir, "../" + "fetch_image_settings.yaml") + sample_db_location = os.path.join(this_dir, "test_server_index.sqlite") self.file_handler = fetch_image.FileHandler() - self.file_handler.update_files_from_server() self.config = fetch_image.FetchImageConfig() self.config.settings["force_download"] = False # Load settings YAML, which defines the parameters we ask for and # acceptable responses from the user - self.config.read_config(self.file_handler.settings_file) + self.config.read_config(yaml_file_location) # Using the config we have, look up URLs to download data from in the # server index - self.db = fetch_image.DB(self.file_handler.index_file) + self.db = fetch_image.DB(sample_db_location) + + super(TestURLLookupFunctions, self).setUp() def test_url_lookup(self): self.settings = self.config.settings @@ -45,10 +51,14 @@ #--- Test first with a snapshot build lookup --- # -- Fix a build date -- - # We only need to look up a single snapshot date. Start with today and - # go with the day in the DB, build 0 - today = wx.DateTime() - today.SetToCurrent() + # We only need to look up a single snapshot date. We just use the + # latest in the database (we could use today and search from it, but + # the database is just one that is checked in, so it could be old + # and db.get_next_prev_day_with_builds may give up before finding it). + date = self.db.execute_return_list( + "SELECT MAX(date) FROM snapshot_binaries")[0][0] + d = re.search("(\d{4})(\d{2})(\d{2})", date) + date = (d.group(1) + "-" + d.group(2) + "-" + d.group(3)) # -- Don't iterate through platforms for snapshot -- @@ -61,7 +71,7 @@ future_date, past_date = self.db.get_next_prev_day_with_builds( "linaro-alip", - today.FormatISODate().encode('ascii'), + date, compatable_hwpacks) if past_date == None: === added file 'linaro_image_tools/tests/test_server_index.sqlite' Binary files linaro_image_tools/tests/test_server_index.sqlite 1970-01-01 00:00:00 +0000 and linaro_image_tools/tests/test_server_index.sqlite 2011-08-11 16:18:34 +0000 differ