def test_save_csv_files_datawarehouse(self, mocked_get_storage_backend): # Mocking the storage backend to local file system with tmp directory. # In this test case we don't want to make usage of the remote Object # Store. mocked_get_storage_backend.return_value = FileSystemStorage( location=self.file_backend_tmp_dir) # Creating a few objects in the database. for i in range(3): SignalFactory.create() datawarehouse.save_csv_files_datawarehouse() # Checking if we have files on the correct locations and that they # do have some content. signals_csv = path.join(self.file_backend_tmp_dir, 'signals.csv') locations_csv = path.join(self.file_backend_tmp_dir, 'locations.csv') reporters_csv = path.join(self.file_backend_tmp_dir, 'reporters.csv') categories_csv = path.join(self.file_backend_tmp_dir, 'categories.csv') statuses_csv = path.join(self.file_backend_tmp_dir, 'statuses.csv') sla_csv = path.join(self.file_backend_tmp_dir, 'sla.csv') self.assertTrue(path.exists(signals_csv)) self.assertTrue(path.getsize(signals_csv)) self.assertTrue(path.exists(locations_csv)) self.assertTrue(path.getsize(locations_csv)) self.assertTrue(path.exists(reporters_csv)) self.assertTrue(path.getsize(reporters_csv)) self.assertTrue(path.exists(categories_csv)) self.assertTrue(path.getsize(categories_csv)) self.assertTrue(path.exists(statuses_csv)) self.assertTrue(path.getsize(statuses_csv)) self.assertTrue(path.getsize(sla_csv))
def task_save_csv_files_datawarehouse(): """Celery task to save CSV files for Datawarehouse. This task is scheduled in Celery beat to run periodically. :returns: """ save_csv_files_datawarehouse()
def handle(self, *args, **options): save_csv_files_datawarehouse()