def get_data(self): exporter = DjangoModelExporter() for model in self.models: adapter = DjangoModelExportAdapter(model) exporter.append(adapter) data = get_data(exporter, file_type=DB_DJANGO) return data
def test_reading_from_more_models(self): model1 = FakeDjangoModel() model2 = FakeDjangoModel() importer = DjangoModelImporter() adapter1 = DjangoModelImportAdapter(model1) adapter1.column_names = self.content['Sheet1'][0] adapter2 = DjangoModelImportAdapter(model2) adapter2.column_names = self.content['Sheet2'][0] importer.append(adapter1) importer.append(adapter2) to_store = { adapter1.get_name(): self.content['Sheet1'][1:], adapter2.get_name(): self.content['Sheet2'][1:] } save_data(importer, to_store, file_type=DB_DJANGO) assert model1.objects.objs == self.result1 assert model2.objects.objs == self.result2 model1._meta.model_name = "Sheet1" model2._meta.model_name = "Sheet2" model1._meta.update(["X", "Y", "Z"]) model2._meta.update(["A", "B", "C"]) exporter = DjangoModelExporter() adapter1 = DjangoModelExportAdapter(model1) adapter2 = DjangoModelExportAdapter(model2) exporter.append(adapter1) exporter.append(adapter2) reader = DjangoBookReader() reader.open_content(exporter) data = reader.read_all() for key in data.keys(): data[key] = list(data[key]) assert data == self.content
def get_data(self): exporter = DjangoModelExporter() for model in self.models: adapter = DjangoModelExportAdapter(model) exporter.append(adapter) data = get_data(exporter, file_type=DB_DJANGO, **self.keywords) return data
def test_special_case_where_only_one_model_used(self): model1 = FakeDjangoModel() importer = DjangoModelImporter() adapter = DjangoModelImportAdapter(model1) adapter.column_names = self.content['Sheet1'][0] importer.append(adapter) to_store = { adapter.get_name(): self.content['Sheet1'][1:], "Sheet2": self.content['Sheet2'][1:] } save_data(importer, to_store, file_type=DB_DJANGO) assert model1.objects.objs == self.result1 model1._meta.model_name = "Sheet1" model1._meta.update(["X", "Y", "Z"]) exporter = DjangoModelExporter() adapter = DjangoModelExportAdapter(model1) exporter.append(adapter) reader = DjangoBookReader() reader.open_content(exporter) data = reader.read_all() assert list(data['Sheet1']) == self.content['Sheet1']
def get_data(self): exporter = DjangoModelExporter() adapter = DjangoModelExportAdapter(self.model) exporter.append(adapter) data = get_data(exporter, file_type=DB_DJANGO, **self.keywords) return data
def get_data(self): exporter = DjangoModelExporter() adapter = DjangoModelExportAdapter(self.model) exporter.append(adapter) data = get_data(exporter, file_type=DB_DJANGO) return data