Ignore:
Timestamp:
18 Dec 2014, 12:58:12 (10 years ago)
Author:
Henrik Bettermann
Message:

Change document_id generation algorithm. Use Universally Unique IDentifiers instead of consecutive numbers.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests/test_browser.py

    r12246 r12256  
    111111        self.browser.getControl(name="doctype").value = ['PDFDocument']
    112112        self.browser.getControl(name="form.title").value = 'My PDF Document'
     113        self.browser.getControl(name="form.document_id").value = 'DOC1'
    113114        self.browser.getControl("Add document").click()
    114115        self.assertTrue('PDF Document added.' in self.browser.contents)
    115         document = self.app['documents']['d101']
     116        document = self.app['documents']['DOC1']
    116117
    117118        # Document can be edited
    118         self.browser.getLink("d101").click()
     119        self.browser.getLink("DOC1").click()
    119120        self.browser.getLink("Manage").click()
    120121        self.browser.getControl(name="form.title").value = 'My first doc'
     
    122123        self.assertTrue('Form has been saved.' in self.browser.contents)
    123124        self.browser.getLink("View").click()
    124         self.assertEqual(self.browser.url, self.container_path + '/d101/index')
     125        self.assertEqual(self.browser.url, self.container_path + '/DOC1/index')
    125126
    126127        # File can be uploaded
     
    149150            name='upload_pdfscanmanageupload').click()
    150151        self.assertTrue(
    151             'href="http://localhost/app/documents/d101/sample.pdf">PDF File</a>'
     152            'href="http://localhost/app/documents/DOC1/sample.pdf">PDF File</a>'
    152153            in self.browser.contents)
    153154        # Browsing the link shows a real pdf only if the document
     
    158159            in self.browser.contents)
    159160        IWorkflowState(document).setState(PUBLISHED)
    160         self.browser.open(self.container_path + '/d101/sample.pdf')
     161        self.browser.open(self.container_path + '/DOC1/sample.pdf')
    161162        self.assertEqual(
    162163            self.browser.headers['content-type'], 'application/pdf')
     
    164165        # Transitions can be performed
    165166        self.assertEqual(document.state, 'published')
    166         self.browser.open(self.container_path + '/d101')
     167        self.browser.open(self.container_path + '/DOC1')
    167168        self.browser.getLink("Transition").click()
    168169        self.browser.getControl(name="transition").value = ['retract']
     
    213214        self.browser.getControl("Add document").click()
    214215        self.browser.getControl(name="doctype").value = ['HTMLDocument']
     216        self.browser.getControl(name="form.document_id").value = 'DOC2'
    215217        self.browser.getControl(name="form.title").value = 'My HTML Document'
    216218        self.browser.getControl("Add document").click()
    217219        self.assertTrue('HTML Document added.' in self.browser.contents)
    218         document = self.app['documents']['d101']
     220        document = self.app['documents']['DOC2']
    219221
    220222        # Document can be edited
    221         self.browser.getLink("d101").click()
     223        self.browser.getLink("DOC2").click()
    222224        self.browser.getLink("Manage").click()
    223225        self.browser.getControl(name="form.title").value = 'My second doc'
     
    230232        self.assertTrue('Form has been saved.' in self.browser.contents)
    231233        self.browser.getLink("View").click()
    232         self.assertEqual(self.browser.url, self.container_path + '/d101/index')
     234        self.assertEqual(self.browser.url, self.container_path + '/DOC2/index')
    233235        self.assertTrue(
    234236            '<h1>Hello World</h1>' in self.browser.contents)
     
    241243            '<h1>Hallo Welt</h1>' in self.browser.contents)
    242244        # The content can't be rendered yet
    243         self.browser.open(self.container_path + '/d101/display')
     245        self.browser.open(self.container_path + '/DOC2/display')
    244246        self.assertTrue(
    245247            'The document requested has not yet been published'
     
    249251
    250252        # Transitions can be performed
    251         self.browser.open(self.container_path + '/d101')
     253        self.browser.open(self.container_path + '/DOC2')
    252254        self.browser.getLink("Transition").click()
    253255        self.browser.getControl(name="transition").value = ['publish']
     
    256258
    257259        # The content can be rendered
    258         self.browser.open(self.container_path + '/d101/display')
     260        self.browser.open(self.container_path + '/DOC2/display')
    259261        self.assertTrue(
    260262            '<h1>Hallo Welt</h1>' in self.browser.contents)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests/test_document.py

    r12213 r12256  
    7272        container = DocumentsContainer()
    7373        document = createObject(u'waeup.HTMLDocument')
    74         document_id = document.document_id
     74        document.document_id = u'DOC'
    7575        container.addDocument(document)
    76         self.assertEqual(container[document_id], document)
     76        self.assertEqual(container[document.document_id], document)
    7777        self.assertRaises(TypeError, container.addDocument, object())
    78         self.assertEqual(document_id, 'd123')
     78        self.assertEqual(document.document_id, 'DOC')
    7979        return
    8080
     
    151151        # we can get an image filename for documents not in a container
    152152        doc = PDFDocument()
     153        doc.document_id = u'DOC'
    153154        chooser = IFileStoreNameChooser(doc)
    154155        result = chooser.chooseName('sample.jpg')
    155156        # the file would be stored in a ``_default`` directory.
    156157        self.assertEqual(
    157             result, '__file-document__documents/sample_d123.jpg')
     158            result, '__file-document__documents/sample_DOC.jpg')
    158159        return
Note: See TracChangeset for help on using the changeset viewer.