Пример #1
0
    def setUp(self):
        site_offline_models.registry = {}
        site_offline_models.loaded = False
        sync_models = [
            "collect_offline_app.testmodel",
            "collect_offline_app.testmodelwithfkprotected",
            "collect_offline_app.testmodelwithm2m",
            "collect_offline_app.testmodelhook",
        ]
        site_offline_models.register(sync_models)

        self.export_path = os.path.join(tempfile.gettempdir(), "export")
        if not os.path.exists(self.export_path):
            os.mkdir(self.export_path)
        self.import_path = self.export_path
        IncomingTransaction.objects.all().delete()
        OutgoingTransaction.objects.using("client").all().delete()
        TestModel.objects.all().delete()
        TestModel.objects.using("client").all().delete()
        TestModel.history.all().delete()
        TestModel.history.using("client").all().delete()
        TestModel.objects.using("client").create(f1="model1")
        TestModel.objects.using("client").create(f1="model2")

        tx_exporter = TransactionExporter(export_path=self.export_path,
                                          using="client")
        batch = tx_exporter.export_batch()
        tx_importer = TransactionImporter(import_path=self.import_path)
        self.batch = tx_importer.import_batch(filename=batch.filename)
Пример #2
0
    def setUp(self):
        site_offline_models.registry = {}
        site_offline_models.loaded = False
        sync_models = ["collect_offline_app.testmodeldates"]
        site_offline_models.register(sync_models, wrapper_cls=OfflineModel)

        self.export_path = os.path.join(tempfile.gettempdir(), "export")
        if not os.path.exists(self.export_path):
            os.mkdir(self.export_path)
        self.import_path = self.export_path
        IncomingTransaction.objects.all().delete()
        OutgoingTransaction.objects.using("client").all().delete()
        TestModelDates.objects.all().delete()
        TestModelDates.objects.using("client").all().delete()
        self.date = get_utcnow()
        TestModelDates.objects.using("client").create(f2=self.date.date())

        tx_exporter = TransactionExporter(export_path=self.export_path,
                                          using="client")
        batch = tx_exporter.export_batch()
        tx_importer = TransactionImporter(import_path=self.import_path)
        self.batch = tx_importer.import_batch(filename=batch.filename)

        datetime_format = "%Y-%m-%dT%H:%M:%S.%fZ"
        self.obj = IncomingTransaction.objects.all()[0]
        bad_date = self.date.strftime(datetime_format)
        json_text = self.obj.aes_decrypt(self.obj.tx)
        json_obj = json.loads(json_text)
        json_obj[0]["fields"]["f2"] = bad_date
        json_text = json.dumps(json_obj)
        self.obj.tx = self.obj.aes_encrypt(json_text)
        self.obj.save()
        self.obj = IncomingTransaction.objects.get(id=self.obj.id)
        self.app_config = copy(
            django_apps.get_app_config("django_collect_offline"))
Пример #3
0
 def setUp(self):
     site_offline_models.registry = {}
     site_offline_models.loaded = False
     offline_models = [
         "collect_offline_app.testmodel",
         "collect_offline_app.badtestmodel",
         "collect_offline_app.anotherbadtestmodel",
         "collect_offline_app.yetanotherbadtestmodel",
         "collect_offline_app.testmodelwithfkprotected",
         "collect_offline_app.testmodelwithm2m",
         "collect_offline_app.testofflinemodelnohistorymanager",
         "collect_offline_app.testofflinemodelnouuid",
     ]
     site_offline_models.register(models=offline_models)
Пример #4
0
    def setUp(self):
        site_offline_models.registry = {}
        site_offline_models.loaded = False
        sync_models = [
            "collect_offline_app.testmodel",
            "collect_offline_app.testmodelwithfkprotected",
            "collect_offline_app.testmodelwithm2m",
        ]
        site_offline_models.register(sync_models, wrapper_cls=OfflineModel)

        self.export_path = os.path.join(tempfile.gettempdir(), "export")
        if not os.path.exists(self.export_path):
            os.mkdir(self.export_path)
        self.import_path = self.export_path
        M2m.objects.all().delete()
        M2m.objects.using("client").all().delete()
        OutgoingTransaction.objects.using("client").all().delete()
        IncomingTransaction.objects.all().delete()
        TestModel.objects.all().delete()
        TestModel.objects.using("client").all().delete()
        TestModel.history.all().delete()
        TestModel.history.using("client").all().delete()
from django_collect_offline.site_offline_models import site_offline_models
from django_collect_offline.offline_model import OfflineModel

offline_models = ["django_collect_offline_files.testmodel"]
site_offline_models.register(offline_models, OfflineModel)
Пример #6
0
 def setUp(self):
     TestModel.objects.create(f1="give any one species too much rope ...")
     site_offline_models.registry = {}
     site_offline_models.loaded = False
     sync_models = ["collect_offline_app.testmodel"]
     site_offline_models.register(sync_models)