Browse Source

Merge "py3: Fix expirer container generation" into stable/train

stable/train
Zuul 3 weeks ago
committed by Gerrit Code Review
parent
commit
da59e573ad
2 changed files with 11 additions and 1 deletions
  1. +1
    -1
      swift/common/utils.py
  2. +10
    -0
      test/unit/common/test_utils.py

+ 1
- 1
swift/common/utils.py View File

@@ -4312,7 +4312,7 @@ def get_expirer_container(x_delete_at, expirer_divisor, acc, cont, obj):
"""
shard_int = int(hash_path(acc, cont, obj), 16) % 100
return normalize_delete_at_timestamp(
int(x_delete_at) / expirer_divisor * expirer_divisor - shard_int)
int(x_delete_at) // expirer_divisor * expirer_divisor - shard_int)


class _MultipartMimeFileLikeObject(object):


+ 10
- 0
test/unit/common/test_utils.py View File

@@ -6346,6 +6346,16 @@ class TestParseContentDisposition(unittest.TestCase):
self.assertEqual(attrs, {'name': 'somefile', 'filename': 'test.html'})


class TestGetExpirerContainer(unittest.TestCase):

@mock.patch.object(utils, 'hash_path', return_value=hex(101)[2:])
def test_get_expirer_container(self, mock_hash_path):
container = utils.get_expirer_container(1234, 20, 'a', 'c', 'o')
self.assertEqual(container, '0000001219')
container = utils.get_expirer_container(1234, 200, 'a', 'c', 'o')
self.assertEqual(container, '0000001199')


class TestIterMultipartMimeDocuments(unittest.TestCase):

def test_bad_start(self):


Loading…
Cancel
Save