

@patch_policies(with_ec_default=True)
def test_get_name_and_placement_object_replication(self):
    path = '/device/part/012-345-678-9ab-cde'
    req = Request.blank(path, headers={
        'X-Backend-Storage-Policy-Index': '0',
    })
    (device, partition, suffix_parts, policy) = get_name_and_placement(req, 2, 3, True)
    self.assertEqual(device, 'device')
    self.assertEqual(partition, 'part')
    self.assertEqual(path, '012-345-678-9ab-cde')
    self.assertEqual(policy, POLICIES[0])
    self.assertEqual(policy.policy_type, EC_POLICY)
    path = '/device/part'
    req = Request.blank(path, headers={
        'X-Backend-Storage-Policy-Index': '1',
    })
    (device, partition, suffix_parts, policy) = get_name_and_placement(req, 2, 3, True)
    self.assertEqual(device, 'device')
    self.assertEqual(partition, 'part')
    self.assertEqual(suffix_parts, None)
    self.assertEqual(policy, POLICIES[1])
    self.assertEqual(policy.policy_type, REPL_POLICY)
    path = '/device/part/'
    req = Request.blank(path, headers={
        'X-Backend-Storage-Policy-Index': '1',
    })
    (device, partition, suffix_parts, policy) = get_name_and_placement(req, 2, 3, True)
    self.assertEqual(device, 'device')
    self.assertEqual(partition, 'part')
    self.assertEqual(suffix_parts, '')
    self.assertEqual(policy, POLICIES[1])
    self.assertEqual(policy.policy_type, REPL_POLICY)

dataset/ETHPy150Open openstack/swift/test/unit/common/test_request_helpers.py TestRequestHelpers.test_get_name_and_placement_object_replication/VarMisuse@85/139 `suffix_parts`->`path`