Python3: Fix test/unit/common/test_container_sync_realms.py
Change-Id: I9bb6e55691821891172d375d0bf097148d66010d
This commit is contained in:
parent
b608c9cda7
commit
c4363aa6ea
@ -101,7 +101,7 @@ class ContainerSyncRealms(object):
|
|||||||
def realms(self):
|
def realms(self):
|
||||||
"""Returns a list of realms."""
|
"""Returns a list of realms."""
|
||||||
self._reload()
|
self._reload()
|
||||||
return self.data.keys()
|
return list(self.data.keys())
|
||||||
|
|
||||||
def key(self, realm):
|
def key(self, realm):
|
||||||
"""Returns the key for the realm."""
|
"""Returns the key for the realm."""
|
||||||
@ -126,7 +126,7 @@ class ContainerSyncRealms(object):
|
|||||||
if result:
|
if result:
|
||||||
result = result.get('clusters')
|
result = result.get('clusters')
|
||||||
if result:
|
if result:
|
||||||
result = result.keys()
|
result = list(result.keys())
|
||||||
return result or []
|
return result or []
|
||||||
|
|
||||||
def endpoint(self, realm, cluster):
|
def endpoint(self, realm, cluster):
|
||||||
|
@ -18,6 +18,8 @@ import os
|
|||||||
import unittest
|
import unittest
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from mock import patch
|
from mock import patch
|
||||||
from swift.common.container_sync_realms import ContainerSyncRealms
|
from swift.common.container_sync_realms import ContainerSyncRealms
|
||||||
from test.unit import FakeLogger, temptree
|
from test.unit import FakeLogger, temptree
|
||||||
@ -77,12 +79,19 @@ class TestUtils(unittest.TestCase):
|
|||||||
logger = FakeLogger()
|
logger = FakeLogger()
|
||||||
fpath = os.path.join(tempdir, fname)
|
fpath = os.path.join(tempdir, fname)
|
||||||
csr = ContainerSyncRealms(fpath, logger)
|
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(
|
self.assertEqual(
|
||||||
logger.all_log_lines(),
|
logger.all_log_lines(),
|
||||||
{'error': [
|
{'error': [fmt % (fpath, fpath)]})
|
||||||
"Could not load '%s': File contains no section headers.\n"
|
|
||||||
"file: %s, line: 1\n"
|
|
||||||
"'invalid'" % (fpath, fpath)]})
|
|
||||||
self.assertEqual(csr.mtime_check_interval, 300)
|
self.assertEqual(csr.mtime_check_interval, 300)
|
||||||
self.assertEqual(csr.realms(), [])
|
self.assertEqual(csr.realms(), [])
|
||||||
|
|
||||||
|
1
tox.ini
1
tox.ini
@ -65,6 +65,7 @@ commands =
|
|||||||
test/unit/common/test_base_storage_server.py \
|
test/unit/common/test_base_storage_server.py \
|
||||||
test/unit/common/test_bufferedhttp.py \
|
test/unit/common/test_bufferedhttp.py \
|
||||||
test/unit/common/test_constraints.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_daemon.py \
|
||||||
test/unit/common/test_db.py \
|
test/unit/common/test_db.py \
|
||||||
test/unit/common/test_db_replicator.py \
|
test/unit/common/test_db_replicator.py \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user