def test_stock_data_migration(self):
     stock_data_task(self.stock_api_object)
     self.assertEqual(SupplyPointStatus.objects.all().count(), 5)
     self.assertEqual(StockTransaction.objects.filter(report__domain=TEST_DOMAIN).count(), 16)
     self.assertEqual(DeliveryGroupReport.objects.all().count(), 4)
     self.assertEqual(StockState.objects.all().count(), 6)
     self.assertEqual(StockReport.objects.all().count(), 2)
Beispiel #2
0
def migration_task():
    from custom.ilsgateway.stock_data import ILSStockDataSynchronization
    for config in ILSGatewayConfig.get_all_steady_sync_configs():
        if config.enabled:
            endpoint = ILSGatewayEndpoint.from_config(config)
            ils_bootstrap_domain(ILSGatewayAPI(config.domain, endpoint))
            stock_data_task(ILSStockDataSynchronization(config.domain, endpoint))
            report_run.delay(config.domain)
Beispiel #3
0
 def test_stock_data_migration(self):
     stock_data_task(self.stock_api_object)
     self.assertEqual(SupplyPointStatus.objects.all().count(), 5)
     self.assertEqual(
         StockTransaction.objects.filter(
             report__domain=TEST_DOMAIN).count(), 16)
     self.assertEqual(DeliveryGroupReport.objects.all().count(), 4)
     self.assertEqual(StockState.objects.all().count(), 6)
     self.assertEqual(StockReport.objects.all().count(), 2)
 def test_stock_data_migration(self):
     stock_data_task(self.stock_api_object)
     self.assertEqual(
         StockTransaction.objects.filter(
             report__domain=TEST_DOMAIN).count(), 11)
     self.assertEqual(StockState.objects.all().count(), 8)
     self.assertEqual(
         StockTransaction.objects.filter(subtype='inferred').count(), 1)
     self.assertEqual(StockReport.objects.all().count(), 1)
 def test_stock_data_migration2(self):
     StockDataCheckpoint.objects.create(
         domain=TEST_DOMAIN, api="", limit=1000, offset=0, date=datetime.datetime(2015, 7, 1)
     )
     stock_data_task(self.stock_api_object)
     self.assertEqual(SupplyPointStatus.objects.all().count(), 5)
     self.assertEqual(SupplyPointStatus.objects.all().values_list("location_id", flat=True).distinct().count(), 2)
     self.assertEqual(StockTransaction.objects.filter(report__domain=TEST_DOMAIN).count(), 15)
     self.assertEqual(DeliveryGroupReport.objects.all().count(), 4)
     self.assertEqual(DeliveryGroupReport.objects.all().values_list("location_id", flat=True).distinct().count(), 2)
     self.assertEqual(StockState.objects.all().count(), 6)
     self.assertEqual(StockReport.objects.all().count(), 2)
 def test_stock_data_migration2(self):
     StockDataCheckpoint.objects.create(
         domain=TEST_DOMAIN,
         api='',
         limit=1000,
         offset=0,
         date=datetime.datetime(2015, 7, 1)
     )
     stock_data_task(self.stock_api_object)
     self.assertEqual(StockTransaction.objects.filter(report__domain=TEST_DOMAIN).count(), 11)
     self.assertEqual(StockState.objects.all().count(), 8)
     self.assertEqual(StockTransaction.objects.filter(subtype='inferred').count(), 0)
     self.assertEqual(StockReport.objects.all().count(), 1)
Beispiel #7
0
 def test_stock_data_migration2(self):
     StockDataCheckpoint.objects.create(domain=TEST_DOMAIN,
                                        api='',
                                        limit=1000,
                                        offset=0,
                                        date=datetime.datetime(2015, 7, 1))
     stock_data_task(self.stock_api_object)
     self.assertEqual(SupplyPointStatus.objects.all().count(), 5)
     self.assertEqual(
         StockTransaction.objects.filter(
             report__domain=TEST_DOMAIN).count(), 15)
     self.assertEqual(DeliveryGroupReport.objects.all().count(), 4)
     self.assertEqual(StockState.objects.all().count(), 6)
     self.assertEqual(StockReport.objects.all().count(), 2)
 def test_stock_data_migration2(self):
     StockDataCheckpoint.objects.create(domain=TEST_DOMAIN,
                                        api='',
                                        limit=1000,
                                        offset=0,
                                        date=datetime.datetime(2015, 7, 1))
     stock_data_task(self.stock_api_object)
     self.assertEqual(
         StockTransaction.objects.filter(
             report__domain=TEST_DOMAIN).count(), 11)
     self.assertEqual(StockState.objects.all().count(), 8)
     self.assertEqual(
         StockTransaction.objects.filter(subtype='inferred').count(), 0)
     self.assertEqual(StockReport.objects.all().count(), 1)
    def handle(self, domain, *args, **options):
        if len(args) == 1:
            ilsgateway_id = args[0]
        else:
            ilsgateway_id = 1166  # defaults to bondenzi: http://ilsgateway.com/tz/facility/1166/

        # cleanup
        _cleanup_existing_data(domain, ilsgateway_id)

        # migrate
        config = ILSGatewayConfig.for_domain(domain)
        assert config.enabled, 'ilsgateway sync must be configured for this domain'
        endpoint = ILSGatewayEndpoint.from_config(config)
        stock_data_task(domain, endpoint, get_ilsgateway_data_migrations(), config,
                        test_facilities=[ilsgateway_id])
    def handle(self, domain, *args, **options):
        if len(args) == 1:
            ilsgateway_id = args[0]
        else:
            ilsgateway_id = 1166  # defaults to bondenzi: http://ilsgateway.com/tz/facility/1166/

        # cleanup
        _cleanup_existing_data(domain, ilsgateway_id)

        # migrate
        config = ILSGatewayConfig.for_domain(domain)
        assert config.enabled, 'ilsgateway sync must be configured for this domain'
        endpoint = ILSGatewayEndpoint.from_config(config)
        stock_data_task(domain, endpoint, get_ilsgateway_data_migrations(), config,
                        test_facilities=[ilsgateway_id])
 def test_stock_data_migration(self):
     stock_data_task(self.stock_api_object)
     self.assertEqual(StockTransaction.objects.filter(report__domain=TEST_DOMAIN).count(), 11)
     self.assertEqual(StockState.objects.all().count(), 8)
     self.assertEqual(StockTransaction.objects.filter(subtype='inferred').count(), 1)
     self.assertEqual(StockReport.objects.all().count(), 1)