Python3: Fix test/unit/common/test_container_sync_realms.py

Change-Id: I9bb6e55691821891172d375d0bf097148d66010d
This commit is contained in:
Cyril Roelandt 2019-01-29 03:19:35 +01:00 committed by Pete Zaitcev
parent b608c9cda7
commit c4363aa6ea
3 changed files with 16 additions and 6 deletions

View File

@ -101,7 +101,7 @@ class ContainerSyncRealms(object):
def realms(self):
"""Returns a list of realms."""
self._reload()
return self.data.keys()
return list(self.data.keys())
def key(self, realm):
"""Returns the key for the realm."""
@ -126,7 +126,7 @@ class ContainerSyncRealms(object):
if result:
result = result.get('clusters')
if result:
result = result.keys()
result = list(result.keys())
return result or []
def endpoint(self, realm, cluster):

View File

@ -18,6 +18,8 @@ import os
import unittest
import uuid
import six
from mock import patch
from swift.common.container_sync_realms import ContainerSyncRealms
from test.unit import FakeLogger, temptree
@ -77,12 +79,19 @@ class TestUtils(unittest.TestCase):
logger = FakeLogger()
fpath = os.path.join(tempdir, fname)
csr = ContainerSyncRealms(fpath, logger)
if six.PY2:
fmt = "Could not load '%s': " \
"File contains no section headers.\n" \
"file: %s, line: 1\n" \
"'invalid'"
else:
fmt = "Could not load '%s': " \
"File contains no section headers.\n" \
"file: '%s', line: 1\n" \
"'invalid'"
self.assertEqual(
logger.all_log_lines(),
{'error': [
"Could not load '%s': File contains no section headers.\n"
"file: %s, line: 1\n"
"'invalid'" % (fpath, fpath)]})
{'error': [fmt % (fpath, fpath)]})
self.assertEqual(csr.mtime_check_interval, 300)
self.assertEqual(csr.realms(), [])

View File

@ -65,6 +65,7 @@ commands =
test/unit/common/test_base_storage_server.py \
test/unit/common/test_bufferedhttp.py \
test/unit/common/test_constraints.py \
test/unit/common/test_container_sync_realms.py \
test/unit/common/test_daemon.py \
test/unit/common/test_db.py \
test/unit/common/test_db_replicator.py \