Пример #1
0
 def test_special_case_where_only_one_model_used(self):
     model1=FakeDjangoModel()
     to_store = {
         "Sheet1": self.content['Sheet1'][1:],
         "Sheet2": self.content['Sheet2'][1:]
     }
     save_data(DB_DJANGO, to_store, models={
         "Sheet1": [model1, self.content['Sheet1'][0], None, None]
     })
     assert model1.objects.objs == self.result1
     model1._meta.model_name = "Sheet1"
     model1._meta.update(["X", "Y", "Z"])
     reader = DjangoBookReader([model1])
     data = reader.sheets()
     assert data['Sheet1'] == self.content['Sheet1']
Пример #2
0
 def test_reading_from_more_models(self):
     model1=FakeDjangoModel()
     model2=FakeDjangoModel()
     to_store = {
         "Sheet1": self.content['Sheet1'][1:],
         "Sheet2": self.content['Sheet2'][1:]
     }
     save_data(DB_DJANGO, to_store, models={
         "Sheet1": [model1, self.content['Sheet1'][0], None, None],
         "Sheet2": [model2, self.content['Sheet2'][0], None, None]
     })
     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"])
     reader = DjangoBookReader([model1, model2])
     data = reader.sheets()
     assert data == self.content