Exemplo n.º 1
0
    def setUpClass(cls):
        super().setUpClass()
        parsed_xlsx = [{
            'product': 'Product Low',
            'category': 'Category A',
            'sold': 9,
            'cost': Money(4.7, 'BRL'),
            'total': Money(47.3, 'BRL')
        }, {
            'product': 'Product Low',
            'category': 'Category A',
            'sold': 7,
            'cost': Money(5.70, 'BRL'),
            'total': Money(90.30, 'BRL')
        }, {
            'product': 'Product High',
            'category': 'Category B',
            'sold': 5,
            'cost': Money(3.2, 'BRL'),
            'total': Money(107.5, 'BRL')
        }]

        task_patcher = patch(
            'salesmanagement.importer.tasks.import_sales_task.delay')
        patcher_parser = patch.object(ParserSalesXlsx,
                                      'as_data',
                                      return_value=parsed_xlsx)
        patcher_storage = mock_storage('sales_imported_files/FileName.xlsx')
        notify_patcher = patch("salesmanagement.importer.models.notify",
                               return_value=MagicMock(send=MagicMock()))

        with patcher_storage, patcher_parser, task_patcher, notify_patcher:
            cls.sale_file = SalesImportFileFactory.create(
                company__name='Company Name')
            import_sales_task(cls.sale_file.pk)
Exemplo n.º 2
0
 def setUp(self):
     self.task_patcher = patch(
         'salesmanagement.importer.tasks.import_sales_task.delay')
     self.storage_patcher = mock_storage(
         'sales_imported_files/FileName.xlsx')
     self.notify_patcher = patch("salesmanagement.importer.models.notify",
                                 return_value=MagicMock(send=MagicMock()))
     with self.task_patcher as task_mock, self.storage_patcher, self.notify_patcher as notify_mock:
         self.notify_mock = notify_mock
         self.task_mock = task_mock
         self.obj = SalesImportFileFactory.create(
             company__name='Company Name')
    def setUp(self):
        user = RandomUserFactory(password='******')
        self.client.login(username=user.username, password='******')
        file_path = Path('sales_imported_files/FileName.xlsx')
        data = dict(user=user.pk,
                    company='Company Name',
                    month='01/07/2018',
                    file=get_temporary_text_file(file_path.name))

        task_patcher = patch(
            'salesmanagement.importer.tasks.import_sales_task.delay')
        with mock_storage(file_path.as_posix()), task_patcher:
            self.response = self.client.post(r('importer:sales-import'), data)
Exemplo n.º 4
0
    def setUpClass(cls):
        super().setUpClass()
        task_patcher = patch(
            'salesmanagement.importer.tasks.import_sales_task.delay')
        patcher_parser = patch.object(ParserSalesXlsx,
                                      'as_data',
                                      return_value=[])
        patcher_storage = mock_storage('sales_imported_files/FileName.xlsx')
        notify_patcher = patch("salesmanagement.importer.models.notify",
                               return_value=MagicMock(send=MagicMock()))

        with patcher_storage, patcher_parser, task_patcher, notify_patcher:
            cls.sale_file = SalesImportFileFactory.create(
                company__name='Company Name')
            import_sales_task(cls.sale_file.pk)
    def setUp(self):
        user = RandomUserFactory(password='******')
        company = CompanyFactory.create(name='Company Name')
        month = date(day=1, month=7, year=2018)
        file = get_temporary_text_file("FileName.xlsx")
        data = dict(user=user.pk,
                    company='Company Name',
                    month='01/07/2018',
                    file=file)

        self.client.login(username=user.username, password='******')
        task_patcher = patch(
            'salesmanagement.importer.tasks.import_sales_task.delay')
        storage_partcher = mock_storage('sales_imported_files/FileName.xlsx')

        with storage_partcher, task_patcher:
            self.obj = SalesImportFileFactory.create(company=company,
                                                     month=month)
            self.response = self.client.post(r('importer:sales-import'), data)