def testDocumentArchiveAPI(self):
        "Use client API to store, fetch and delete a document"
        doc_id = document_store(self.tempfile.name, 'longitudinal')
        self.doc_list.append(doc_id)
        self.assertTrue(doc_id)

        # Pull from the store and see if metadata stuck
        metadata = document_fetch_metadata(doc_id)
        self.assertEqual(metadata.get('report_type', None),
                         'longitudinal')
    def testZipCompression(self):
        "Use client API to compress and store a doc"
        doc_id = document_store(document=self.tempfile.name,
                                document_type='longitudinal',
                                compress_with='zip')
        self.doc_list.append(doc_id)

        # Pull from the store and see if compressed
        metadata = document_fetch_metadata(doc_id)
        self.assertEqual(metadata.get('compression', None),
                         'zip')
        filename = os.path.basename(self.tempfile.name) + '.zip'
        self.assertEqual(self.test_text,
                         document_find({'filename': filename}))
    def testDocumentArchiveMetaData(self):
        "Persist and test additional metadata with a document"
        now = datetime.now()
        metadata = {'include_updates': True, 'jon': 'bon',
                    'report_type': 'foo', 'time_of_day': now}
        doc_id = document_store(self.tempfile.name, 'longitudinal',
                                **metadata)
        self.doc_list.append(doc_id)
        self.assertTrue(doc_id)

        # Pull from the store and see if metadata stuck
        metadata = document_fetch_metadata(doc_id)
        self.assertEqual(metadata['include_updates'], True)
        self.assertEqual(metadata['jon'], 'bon')
        self.assertEqual(metadata['time_of_day'], now.isoformat())