Beispiel #1
0
    def handle(self, *args, **options):
        logger.info('Dump Horeca CSV files per sub category')

        self._validate_arguments(options)

        csv_files = create_csv_files(isoweek=options['isoweek'],
                                     isoyear=options['isoyear'])

        for csv_file in csv_files:
            logger.info('Created file "{}"'.format(csv_file))
Beispiel #2
0
    def test_create_csv_files_save(self, patched_model):
        # Usage of Django storage means the difference between local and remote
        # storage is abstracted away, so the previously 2 tests were merged.
        patched_model.uploaded_file = mock.MagicMock()
        patched_model.uploaded_file.save = mock.MagicMock()

        # create a Signal with a horeca sub-category
        main_category = _get_horeca_main_category()
        category = Category.objects.filter(
            parent_id__isnull=False, parent_id=main_category.pk).first()

        SignalFactory.create(category_assignment__category=category)
        self.assertEqual(Signal.objects.count(), 1)

        # Check that the storage backend is called, and that shutil.copy is not.
        csv_files = create_csv_files(isoweek=1, isoyear=2019)

        self.assertEqual(len(csv_files), 7)
Beispiel #3
0
    def test_create_csv_files(self):
        csv_files = create_csv_files(isoweek=1, isoyear=2019)

        self.assertGreater(len(csv_files), 0)