From 6e7ca26169bcf6f2b51bddddb921b10c252e29d9 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 5 Oct 2018 21:42:46 +0000 Subject: [PATCH] DB follow-up Change-Id: I32cff110f0771d6d92a881ef52e482aa17d8dbe4 Related-Change: I0dab4ff013f300396cff7313bc27b9d5644fe8a7 --- swift/common/db.py | 4 ++-- test/unit/common/test_db.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/swift/common/db.py b/swift/common/db.py index 1e3fc385a7..62fb89635a 100644 --- a/swift/common/db.py +++ b/swift/common/db.py @@ -884,8 +884,8 @@ class DatabaseBroker(object): if not check_utf8(value): raise HTTPBadRequest('Metadata must be valid UTF-8') key = key.lower() - if len(value) != 0 and (key.startswith('x-account-meta') or - key.startswith('x-container-meta')): + if value and key.startswith(('x-account-meta-', + 'x-container-meta-')): prefix = 'x-account-meta-' if key.startswith('x-container-meta-'): prefix = 'x-container-meta-' diff --git a/test/unit/common/test_db.py b/test/unit/common/test_db.py index 0f48c94fbb..effa2d1bea 100644 --- a/test/unit/common/test_db.py +++ b/test/unit/common/test_db.py @@ -687,11 +687,9 @@ class TestDatabaseBroker(unittest.TestCase): stub_dict = {} def stub(*args, **kwargs): - for key in list(stub_dict.keys()): - del stub_dict[key] + stub_dict.clear() stub_dict['args'] = args - for key, value in kwargs.items(): - stub_dict[key] = value + stub_dict.update(kwargs) broker = DatabaseBroker(':memory:') broker._initialize = stub broker.initialize(normalize_timestamp('1'))