

def test_add_no_container_no_create(self):
    '\n        Tests that adding an image with a non-existing container\n        raises an appropriate exception\n        '
    conf = copy.deepcopy(SWIFT_CONF)
    conf['swift_store_user'] = 'tenant:user'
    conf['swift_store_create_container_on_put'] = False
    conf['swift_store_container'] = 'noexist'
    self.config(**conf)
    moves.reload_module(swift)
    self.mock_keystone_client()
    self.store = Store(self.conf)
    self.store.configure()
    image_swift = six.BytesIO(b'nevergonnamakeit')
    global SWIFT_PUT_OBJECT_CALLS
    SWIFT_PUT_OBJECT_CALLS = 0
    exception_caught = False
    try:
        self.store.add(str(uuid.uuid4()), image_swift, 0)
    except BackendException as e:
        exception_caught = True
        self.assertIn('container noexist does not exist in Swift', encodeutils.exception_to_unicode(e))
    self.assertTrue(exception_caught)
    self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 0)

dataset/ETHPy150Open openstack/glance_store/glance_store/tests/unit/test_swift_store.py SwiftTests.test_add_no_container_no_create/original