Index: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py	(revision 12204)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py	(revision 12205)
@@ -268,10 +268,10 @@
         the customers container this chooser would create:
 
-          ``'__file-customerdocument__customers/A/A123456/nice_image_d123_A123456.jpeg'``
+          ``'__file-customerdocument__customers/345/c999/nice_image_d123_c999.jpeg'``
 
         meaning that the nice image of this customer document would be
         stored in the site-wide file storage in path:
 
-          ``customers/A/A123456/nice_image_d123_A123456.jpeg``
+          ``customers/345/c999/nice_image_d123_c999.jpeg``
 
         """
Index: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_document.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_document.py	(revision 12204)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_document.py	(revision 12205)
@@ -19,13 +19,22 @@
 Tests for documents.
 """
+import shutil
+import tempfile
+import grok
+from StringIO import StringIO
 from zope.interface.verify import verifyClass, verifyObject
-from zope.component import createObject
+from zope.component import createObject, queryUtility
 from hurry.workflow.interfaces import (
     IWorkflowInfo, IWorkflowState, InvalidTransitionError)
+from waeup.ikoba.interfaces import (
+    IObjectHistory, IFileStoreNameChooser, IFileStoreHandler)
+from waeup.ikoba.imagestorage import DefaultStorage
 from waeup.ikoba.customers.interfaces import (
     ICustomerDocumentsContainer, ICustomerDocument)
 from waeup.ikoba.interfaces import IObjectHistory
+from waeup.ikoba.customers.customer import Customer
 from waeup.ikoba.customers.documents import (
-    CustomerDocumentsContainer, CustomerSampleDocument)
+    CustomerDocumentsContainer, CustomerSampleDocument,
+    CustomerDocumentFileStoreHandler, CustomerDocumentFileNameChooser)
 from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase)
 
@@ -87,2 +96,76 @@
         self.assertTrue('Document created by system' in messages)
         return
+
+
+class CustomerDocumentFileTests(FunctionalTestCase):
+
+    layer = FunctionalLayer
+
+    def setUp(self):
+        super(CustomerDocumentFileTests, self).setUp()
+        self.workdir = tempfile.mkdtemp()
+        return
+
+    def tearDown(self):
+        super(CustomerDocumentFileTests, self).tearDown()
+        shutil.rmtree(self.workdir)
+        return
+
+    def test_file_store_handler_util_accessible(self):
+        # we can get an IFileStoreHandler utility for documents
+        handler = queryUtility(IFileStoreHandler, name='file-customerdocument')
+        self.assertTrue(
+            isinstance(handler, CustomerDocumentFileStoreHandler))
+        return
+
+    def test_file_store_handler(self):
+        store = DefaultStorage()
+        handler = queryUtility(IFileStoreHandler, name='file-customerdocument')
+        result = handler.pathFromFileID(
+            store, '/fake-root', '__anything__345/c999/nice_image_d123_c999.jpeg')
+        self.assertEqual(
+            result, '/fake-root/customers/345/c999/nice_image_d123_c999')
+        return
+
+    def test_file_store_handler_create(self):
+        # we can create files in image store with the document file
+        # store handler
+        store = DefaultStorage(self.workdir)
+        handler = queryUtility(IFileStoreHandler, name='file-customerdocument')
+        file_obj, path, waeup_file = handler.createFile(
+            store, store.root, 'sample.jpg', '__anything__345/c999/nice_image_d123_c999.jpeg',
+            StringIO('I am a JPG file'))
+        self.assertEqual(path[-43:], 'customers/345/c999/nice_image_d123_c999.jpg')
+        return
+
+    def test_iface(self):
+        # make sure we implement promised interfaces
+        obj = CustomerDocumentFileNameChooser(None) # needs a context normally
+        verifyClass(IFileStoreNameChooser, CustomerDocumentFileNameChooser)
+        verifyObject(IFileStoreNameChooser, obj)
+        return
+
+    def test_name_chooser_available(self):
+        # we can get a name chooser for document objects as adapter
+        doc = CustomerSampleDocument()
+        chooser = IFileStoreNameChooser(doc)
+        self.assertTrue(chooser is not None)
+        return
+
+    def test_name_chooser_document(self):
+        # we can't get an image filename for documents not owned by a customer
+        doc = CustomerSampleDocument()
+        chooser = IFileStoreNameChooser(doc)
+        # no customer can be found
+        self.assertRaises(AttributeError, chooser.chooseName, 'sample.jpg')
+        # we add a fake customer and fake documents container and can get
+        # an image name
+        fake_customer = Customer()
+        fake_customer.customer_id = u'K1000001'
+        fake_container = grok.Container()
+        fake_container.__parent__ = fake_customer
+        doc.__parent__ = fake_container
+        result = chooser.chooseName('sample.jpg')
+        self.assertEqual(
+            result, '__file-customerdocument__01000/K1000001/sample_d123_K1000001.jpg')
+        return
