From patchwork Wed Sep 12 18:28:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Terceiro X-Patchwork-Id: 11367 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 B32B323E29 for ; Wed, 12 Sep 2012 18:28:14 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1B10540F9C85 for ; Wed, 12 Sep 2012 18:28:14 +0000 (UTC) Received: by iafj25 with SMTP id j25so1497006iaf.11 for ; Wed, 12 Sep 2012 11:28:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=KmvmTaa89qh0KTO/Nri4oIyjz50Jlz+ifIn9yJrk7TQ=; b=bKw6zkaptwE8oYK2uPAwVBtFeaPWtzX2VL+EmxJT92CrmngPH/IoKV6VzO5Rtgaxef CKEgWvEPHwv907bKE4oD1gmlRjUiO4vUad4Ozu8w1MMqgt8cPqTsO9tpQYRPWbyAjUEn 8o/xv/0P2jH7c20VrLnYdUA+G9+TD6LIfP8OBNqYSdnOSKqaCSufcqLqnvDpsD3dgp/3 ZB73GTYvh9zhMEmiuIst3HCxUJQ0n2e6hv5sEIdX/iXbOPJX8WYkcAJ9y6bVyIkZBiUO FFNn3gygXMU5K1JrpUkV/Y7sRT+3GNkLfmNWBxfrzGNq5gPad+VdwCHo4iGW6OVrLfeW VZaA== Received: by 10.50.195.134 with SMTP id ie6mr22291688igc.28.1347474493493; Wed, 12 Sep 2012 11:28:13 -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.50.184.232 with SMTP id ex8csp87092igc; Wed, 12 Sep 2012 11:28:12 -0700 (PDT) Received: by 10.180.84.169 with SMTP id a9mr34593907wiz.8.1347474491589; Wed, 12 Sep 2012 11:28:11 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id o1si28099407wea.147.2012.09.12.11.28.11 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 11:28:11 -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 1TBrfX-0003Yg-0Z for ; Wed, 12 Sep 2012 18:28:11 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id E4B31E2BA2 for ; Wed, 12 Sep 2012 18:28:10 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 379 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 379: Make configuration keys with blank value and a default return the default Message-Id: <20120912182810.9143.36825.launchpad@ackee.canonical.com> Date: Wed, 12 Sep 2012 18:28:10 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15936"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: f604d6b63a4a377e505e3178dab63aa474e57785 X-Gm-Message-State: ALoCoQmmYkTh5LcsonvB2vVmZ8p63bHt6HyL2OMJqAcYXCztmorodTtjdyFGCDiXgxn6eec3hJjj Merge authors: Antonio Terceiro (terceiro) Related merge proposals: https://code.launchpad.net/~terceiro/lava-dispatcher/fix-1032467/+merge/123833 proposed by: Antonio Terceiro (terceiro) review: Approve - Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 379 [merge] fixes bug: https://launchpad.net/bugs/1032467 committer: Antonio Terceiro branch nick: lava-dispatcher timestamp: Wed 2012-09-12 15:21:49 -0300 message: Make configuration keys with blank value and a default return the default modified: lava_dispatcher/config.py lava_dispatcher/tests/test_config.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === modified file 'lava_dispatcher/config.py' --- lava_dispatcher/config.py 2012-08-08 22:30:52 +0000 +++ lava_dispatcher/config.py 2012-09-11 21:00:08 +0000 @@ -80,7 +80,10 @@ self.config_dir = config_dir def get(self, key, default=_sentinel): try: - return self.cp.get("DEFAULT", key) + val = self.cp.get("DEFAULT", key) + if default is not _sentinel and val == '': + val = default + return val except NoOptionError: if default is not _sentinel: return default === modified file 'lava_dispatcher/tests/test_config.py' --- lava_dispatcher/tests/test_config.py 2011-11-28 20:27:03 +0000 +++ lava_dispatcher/tests/test_config.py 2012-09-12 18:09:46 +0000 @@ -22,11 +22,29 @@ from lava_dispatcher.config import get_config, get_device_config from lava_dispatcher.utils import string_to_list +from lava_dispatcher.client.base import LavaClient test_config_dir = os.path.join(os.path.dirname(__file__), 'test-config') print test_config_dir +tmp_dir = os.getenv("TMPDIR") or '/tmp' +tmp_config_dir = os.path.join(tmp_dir, 'lava-dispatcher-config') + +def create_config(name, data): + filename = os.path.join(tmp_config_dir, name) + os.mkdir(os.path.dirname(filename)) + with open(filename, 'w') as f: + for key in data.keys(): + f.write("%s = %s\n" % (key, data[key])) + class TestConfigData(TestCase): + + def setUp(self): + os.mkdir(tmp_config_dir) + + def tearDown(self): + os.system('rm -rf %s' % tmp_config_dir) + def test_beagle01_uboot_cmds(self): beagle01_config = get_device_config("beaglexm01", test_config_dir) expected = [ @@ -48,3 +66,8 @@ lava_server_ip = server_config.get("LAVA_SERVER_IP") self.assertEqual(expected, lava_server_ip) + def test_default_value_for_tester_hostname(self): + create_config('devices/qemu01.conf', { 'device_type': 'qemu' }) + config = get_device_config("qemu01", tmp_config_dir) + client = LavaClient(None, config) + self.assertEqual('linaro', client.tester_hostname)