def test_insert_file(self):
     """Ensure we can properly insert a file into ElasticSearch
     """
     test_data = " ".join(str(x) for x in range(100000)).encode("utf8")
     docc = {
         "_id": "test_id",
         "filename": "test_filename",
         "upload_date": 5,
         "md5": "test_md5",
     }
     self.elastic_doc.insert_file(MockGridFSFile(docc, test_data), *TESTARGS)
     res = self._search()
     for doc in res:
         self.assertEqual(doc["_id"], docc["_id"])
         self.assertEqual(doc["filename"], docc["filename"])
         self.assertEqual(base64.b64decode(doc["content"]), test_data.strip())
예제 #2
0
    def test_remove_file(self):
        test_data = b'hello world'
        docc = {
            '_id': 'test_id',
            'filename': 'test_filename',
            'upload_date': datetime.datetime.now(),
            'md5': 'test_md5'
        }

        self.docman.insert_file(MockGridFSFile(docc, test_data), *TESTARGS)
        res = self.solr_conn.search('*:*')
        self.assertEqual(len(res), 1)

        self.docman.remove(docc['_id'], *TESTARGS)
        res = self.solr_conn.search('*:*')
        self.assertEqual(len(res), 0)
예제 #3
0
 def test_insert_file(self):
     # Drop database, so that mongo_doc's client refreshes its index cache.
     self.choosy_docman.mongo.drop_database("test")
     test_data = " ".join(str(x) for x in range(100000)).encode("utf8")
     docc = {
         "_id": "test_id",
         "filename": "test_filename",
         "upload_date": 5,
         "md5": "test_md5",
     }
     self.choosy_docman.insert_file(MockGridFSFile(docc, test_data), *TESTARGS)
     res = self._search()
     for doc in res:
         self.assertEqual(doc[self.id_field], docc["_id"])
         self.assertEqual(doc["filename"], docc["filename"])
         self.assertEqual(doc["content"], test_data)
 def test_insert_file(self):
     # Drop database, so that mongo_doc's client refreshes its index cache.
     self.choosy_docman.mongo.drop_database('test')
     test_data = ' '.join(str(x) for x in range(100000)).encode('utf8')
     docc = {
         '_id': 'test_id',
         'filename': 'test_filename',
         'upload_date': 5,
         'md5': 'test_md5'
     }
     self.choosy_docman.insert_file(MockGridFSFile(docc, test_data),
                                    *TESTARGS)
     res = self._search()
     for doc in res:
         self.assertEqual(doc[self.id_field], docc['_id'])
         self.assertEqual(doc['filename'], docc['filename'])
         self.assertEqual(doc['content'], test_data)
예제 #5
0
 def test_insert_file(self):
     """Ensure we can properly insert a file into ElasticSearch
     """
     test_data = ' '.join(str(x) for x in range(100000)).encode('utf8')
     docc = {
         '_id': 'test_id',
         'filename': 'test_filename',
         'upload_date': 5,
         'md5': 'test_md5'
     }
     self.elastic_doc.insert_file(
         MockGridFSFile(docc, test_data), *TESTARGS)
     res = self._search()
     for doc in res:
         self.assertEqual(doc['_id'], docc['_id'])
         self.assertEqual(doc['filename'], docc['filename'])
         self.assertEqual(base64.b64decode(doc['content']),
                          test_data.strip())
    def test_remove_file(self):
        test_data = b"hello world"
        docc = {
            "_id": "test_id",
            "_ts": 10,
            "ns": "test.test",
            "filename": "test_filename",
            "upload_date": 5,
            "md5": "test_md5",
        }

        self.elastic_doc.insert_file(MockGridFSFile(docc, test_data), *TESTARGS)
        res = list(self._search())
        self.assertEqual(len(res), 1)

        self.elastic_doc.remove("test_id", *TESTARGS)
        res = list(self._search())
        self.assertEqual(len(res), 0)
예제 #7
0
 def test_insert_file(self):
     """Ensure we can properly insert a file into Solr via DocManager.
     """
     test_data = ' '.join(str(x) for x in range(100000)).encode('utf8')
     docc = {
         '_id': 'test_id',
         'filename': 'test_filename',
         'upload_date': datetime.datetime.now(),
         'md5': 'test_md5'
     }
     self.docman.insert_file(MockGridFSFile(docc, test_data), *TESTARGS)
     res = self.solr_conn.search('*:*')
     for doc in res:
         self.assertEqual(doc['_id'], docc['_id'])
         self.assertEqual(doc['filename'], docc['filename'])
         content = doc.get('content', doc.get('_text_', None))
         self.assertTrue(content)
         self.assertIn(test_data.strip(), content[0].strip().encode('utf8'))
예제 #8
0
    def test_remove_file(self):
        # Drop database, so that mongo_doc's client refreshes its index cache.
        self.choosy_docman.mongo.drop_database("test")
        test_data = b"hello world"
        docc = {
            "_id": "test_id",
            "filename": "test_filename",
            "upload_date": 5,
            "md5": "test_md5",
        }

        self.choosy_docman.insert_file(MockGridFSFile(docc, test_data), *TESTARGS)
        res = list(self._search())
        self.assertEqual(len(res), 1)

        self.choosy_docman.remove(docc["_id"], *TESTARGS)
        res = list(self._search())
        self.assertEqual(len(res), 0)
예제 #9
0
    def test_remove_file(self):
        test_data = b'hello world'
        docc = {
            '_id': 'test_id',
            '_ts': 10,
            'ns': 'test.test',
            'filename': 'test_filename',
            'upload_date': 5,
            'md5': 'test_md5'
        }

        self.elastic_doc.insert_file(
            MockGridFSFile(docc, test_data), *TESTARGS)
        res = list(self._search())
        self.assertEqual(len(res), 1)

        self.elastic_doc.remove('test_id', *TESTARGS)
        res = list(self._search())
        self.assertEqual(len(res), 0)
    def test_remove_file(self):
        # Drop database, so that mongo_doc's client refreshes its index cache.
        self.choosy_docman.mongo.drop_database('test')
        test_data = b'hello world'
        docc = {
            '_id': 'test_id',
            'filename': 'test_filename',
            'upload_date': 5,
            'md5': 'test_md5'
        }

        self.choosy_docman.insert_file(MockGridFSFile(docc, test_data),
                                       *TESTARGS)
        res = list(self._search())
        self.assertEqual(len(res), 1)

        self.choosy_docman.remove(docc['_id'], *TESTARGS)
        res = list(self._search())
        self.assertEqual(len(res), 0)