def setUp(self):
        self.db = TemporaryS3BlobDB(settings.S3_BLOB_DB_SETTINGS)
        assert get_blob_db() is self.db, (get_blob_db(), self.db)
        data = b'binary data not valid utf-8 \xe4\x94'

        self.blob_metas, self.not_founds = [], set()
        for domain, type_code in (('a', CODES.form_xml),
                                  ('a', CODES.application), ('b',
                                                             CODES.form_xml)):
            self.blob_metas.append(
                self.db.put(BytesIO(data),
                            meta=new_meta(domain=domain, type_code=type_code)))
            lost = new_meta(domain=domain,
                            type_code=CODES.form_xml,
                            content_length=42)
            lost.save()
            self.blob_metas.append(lost)
            self.not_founds.add((
                lost.id,
                lost.domain,
                lost.type_code,
                lost.parent_id,
                lost.key,
            ))

        discard_migration_state(self.slug)
        discard_migration_state(self.slug, domain='a')
Пример #2
0
 def tearDown(self):
     try:
         for doc in self.couch_docs:
             doc.class_.get_db().delete_doc(doc.id)
         for doc in self.sql_docs:
             doc.obj.delete()
         discard_migration_state(self.slug)
     finally:
         super(TestMigrateBackend, self).tearDown()
Пример #3
0
 def tearDown(self):
     try:
         for doc in self.couch_docs:
             doc.class_.get_db().delete_doc(doc.id)
         for doc in self.sql_docs:
             doc.obj.delete()
         discard_migration_state(self.slug)
     finally:
         super(TestMigrateBackend, self).tearDown()
Пример #4
0
    def setUp(self):
        super(TestMigrateBackend, self).setUp()

        self.not_founds = set()
        self.couch_docs = []
        for doc_type, doc_class in self.couch_doc_types.items():
            obj = doc_class()
            if hasattr(doc_class, "domain"):
                domain = obj.domain = "test"
            elif doc_class is mod.Domain:
                domain = obj.name = "test"
            elif doc_type in self.shared_domain_doc_types:
                domain = mod.SHARED_DOMAIN
            else:
                domain = mod.UNKNOWN_DOMAIN
            obj.doc_type = doc_type
            doc = obj.to_json()
            doc["external_blobs"] = {
                "blob":
                OldCouchBlobMeta(
                    id=doc_type.lower(),
                    content_type="text/plain",
                    content_length=7,
                ).to_json()
            }
            doc_class.get_db().save_doc(doc)
            self.couch_docs.append(CouchDoc(doc_class, doc_type, domain, doc))

        def create_sql_doc(rex):
            key = uuid.uuid4().hex
            obj = rex.model_class()
            save_attr = rex.model_class.__name__ + "_save"
            return getattr(self, save_attr)(obj, key)

        self.sql_docs = []
        for rex in (x() for x in self.sql_reindex_accessors):
            self.sql_docs.append(create_sql_doc(rex))

        self.test_size = len(self.couch_docs) + len(self.sql_docs)
        discard_migration_state(self.slug)
Пример #5
0
    def setUp(self):
        super(TestMigrateBackend, self).setUp()

        self.not_founds = set()
        self.couch_docs = []
        for doc_type, doc_class in self.couch_doc_types.items():
            obj = doc_class()
            if hasattr(doc_class, "domain"):
                domain = obj.domain = "test"
            elif doc_class is mod.Domain:
                domain = obj.name = "test"
            elif doc_type in self.shared_domain_doc_types:
                domain = mod.SHARED_DOMAIN
            else:
                domain = mod.UNKNOWN_DOMAIN
            obj.doc_type = doc_type
            doc = obj.to_json()
            doc["external_blobs"] = {"blob": OldCouchBlobMeta(
                id=doc_type.lower(),
                content_type="text/plain",
                content_length=7,
            ).to_json()}
            doc_class.get_db().save_doc(doc)
            self.couch_docs.append(CouchDoc(doc_class, doc_type, domain, doc))

        def create_sql_doc(rex):
            key = uuid.uuid4().hex
            obj = rex.model_class()
            save_attr = rex.model_class.__name__ + "_save"
            return getattr(self, save_attr)(obj, key)
        self.sql_docs = []
        for rex in (x() for x in self.sql_reindex_accessors):
            self.sql_docs.append(create_sql_doc(rex))

        self.test_size = len(self.couch_docs) + len(self.sql_docs)
        discard_migration_state(self.slug)
 def tearDown(self):
     self.db.close()
     discard_migration_state(self.slug)
     discard_migration_state(self.slug, domain='a')
     for doc in self.blob_metas:
         doc.delete()