def test_13_complete_task_history_product_retailer(self):
        """ Test Price History Product Retailer
        """
        print(">>>>>", "Test Price History Product Retailer")
        # Import celery task
        from app.celery_app import main_task
        from app.models.history_product import Product

        # Filters for the task
        params = {
            "item_uuid": "fd960578-71ae-463e-84d5-0e451d184597",
            "retailer": "walmart"
        }

        celery_task = main_task.apply_async(args=(Product.start_retailer_task,
                                                  params))
        print("Submitted Task: ", celery_task.id)
        # Get the task from the celery task
        time.sleep(2)
        task = Task(celery_task.id)
        print('Created task instance!')

        # Check result of task
        while task.is_running():
            print("Waiting for task to finish")
            print(task.task_id)
            print(task.progress)
            print(task.status)
            time.sleep(1)

        prog = task.status['progress']
        print("Final progress: {}".format(prog))
        print("Result keys: {} ".format(list(task.result.keys())))
        self.assertEqual(prog, 100)
    def test_11_complete_task_count_by_retailer_engine(self):
        """ Test count by retailer engine
        """
        print(">>>>>", "Test Count by retailer engine")
        # Import celery task
        from app.celery_app import main_task
        from app.models.history_product import Product

        # Filters for the task
        params = {"date": "2019-05-24 19:17:06", "retailer": "walmart"}

        celery_task = main_task.apply_async(
            args=(Product.count_by_retailer_engine_task, params))
        print("Submitted Task: ", celery_task.id)
        # Get the task from the celery task
        time.sleep(2)
        task = Task(celery_task.id)
        print('Created task instance!')

        # Check result of task
        while task.is_running():
            print("Waiting for task to finish")
            print(task.task_id)
            print(task.progress)
            print(task.status)
            time.sleep(1)

        prog = task.status['progress']
        print("Final progress: {}".format(prog))
        print("Result keys: {} ".format(list(task.result.keys())))
        self.assertEqual(prog, 100)
Beispiel #3
0
    def test_08_fail_task_price_map_decorator(self):
        """ Test Map task without filters
        """
        print(">>>>", "Test Map task without filters")
        # Import celery task
        from app.celery_app import main_task
        from app.models.geo_mapa import Map

        # Filters for the task -> missing filters
        params = {
            "retailers": {
                "walmart": "Walmart",
                "superama": "Superama"
            },
            "date_start": "2019-01-10",
            "date_end": "2019-01-13",
            "interval": "day"
        }
        celery_task = main_task.apply_async(args=(Map.start_task, params))
        task = Task(celery_task.id)
        print("Submitted Task: ", celery_task.id)
        # Check result of task
        while task.is_running():
            time.sleep(1)

        prog = task.status['progress']
        print("Final progress: {}".format(prog))
        print("Result keys: {} ".format(list(task.result.keys())))

        self.assertEqual(prog, -1)
Beispiel #4
0
    def test_09_complete_task_price_historia_decorator(self):
        """ Test price Geo Historia Decorator
        """
        print(">>>>>", "Test price Geo Historia Decorator")
        # Import celery task
        from app.celery_app import main_task
        from app.models.geo_historia import Historia

        # Filters for the task
        params = {
            "filters": [{
                "item_uuid": "fd960578-71ae-463e-84d5-0e451d184597"
            }, {
                "item_uuid": "7f177768-cd76-45e4-92ac-9bab4ec8d8b3"
            }, {
                "item_uuid": "63aa59b6-04a7-45ed-99df-8f6d1403c4de"
            }, {
                "item_uuid": "facdc537-d80f-447e-9d6e-0266e0e9d082"
            }, {
                "retailer": "walmart"
            }],
            "retailers": {
                "walmart": "Walmart",
                "superama": "Superama"
            },
            "date_start":
            "2019-05-19",
            "date_end":
            "2019-05-21",
            "interval":
            "day"
        }

        celery_task = main_task.apply_async(args=(Historia.filters_task,
                                                  params))
        print("Submitted Task: ", celery_task.id)
        # Get the task from the celery task
        time.sleep(2)
        task = Task(celery_task.id)
        print('Created task instance!')

        # Check result of task
        while task.is_running():
            print("Waiting for task to finish")
            print(task.task_id)
            print(task.progress)
            print(task.status)
            time.sleep(1)

        prog = task.status['progress']
        print("Final progress: {}".format(prog))
        print("Result keys: {} ".format(list(task.result.keys())))

        self.assertEqual(prog, 100)
    def test_09_complete_task_compare_store_item(self):
        """ Test compare store item
        """
        print(">>>>>", "Test Compare store item")
        # Import celery task
        from app.celery_app import main_task
        from app.models.history_product import Product

        # Filters for the task
        params = {
            "fixed_segment": {
                "store_uuid": "1e3d5b76-7ace-11e7-9b9f-0242ac110003",
                "item_uuid": "12e4f953-0595-4d3f-8024-aa04c2ec60eb",
                "retailer": "walmart",
                "name": "Test Name"
            },
            "added_segments": [{
                "store_uuid": "1e3d5b76-7ace-11e7-9b9f-0242ac110003",
                "item_uuid": "12e4f953-0595-4d3f-8024-aa04c2ec60eb",
                "retailer": "walmart",
                "name": "Test Name"
            }],
            "date_ini":
            "2019-05-28",
            "date_fin":
            "2019-05-29"
        }

        celery_task = main_task.apply_async(
            args=(Product.compare_store_item_task, params))
        print("Submitted Task: ", celery_task.id)
        # Get the task from the celery task
        time.sleep(2)
        task = Task(celery_task.id)
        print('Created task instance!')

        # Check result of task
        while task.is_running():
            print("Waiting for task to finish")
            print(task.task_id)
            print(task.progress)
            print(task.status)
            time.sleep(1)

        prog = task.status['progress']
        print("Final progress: {}".format(prog))
        print("Result keys: {} ".format(list(task.result.keys())))
        self.assertEqual(prog, 100)
    def test_15_complete_task_history_product_compare_stores(self):
        """ Test Price History Product Compare Stores
        """
        print(">>>>>", "Test Price History Product Compare Stores")
        # Import celery task
        from app.celery_app import main_task
        from app.models.history_product import Product

        # Filters for the task
        params = {
            "date":
            "2019-05-31",
            "fixed_segment": {
                "item_uuid": "c9b175c8-460c-4969-a3b6-dd14d9a169dd",
                "retailer": "walmart"
            },
            "added_segments": [{
                "item_uuid": "d4cae6a5-ea9e-40c9-b1d5-6a2ed6656fc5",
                "retailer": "soriana"
            }],
            "territory": []
        }

        celery_task = main_task.apply_async(
            args=(Product.start_compare_stores_task, params))
        print("Submitted Task: ", celery_task.id)
        # Get the task from the celery task
        time.sleep(2)
        task = Task(celery_task.id)
        print('Created task instance!')

        # Check result of task
        while task.is_running():
            print("Waiting for task to finish")
            print(task.task_id)
            print(task.progress)
            print(task.status)
            time.sleep(1)

        prog = task.status['progress']
        print("Final progress: {}".format(prog))
        print("Result keys: {} ".format(list(task.result.keys())))
        self.assertEqual(prog, 100)
    def test_07_complete_task_count_by_source(self):
        """ Test count by source task
        """
        print(">>>>>", "Test Count by Source")
        # Import celery task
        from app.celery_app import main_task
        from app.models.history_product import Product

        # Filters for the task
        params = {
            "store_id": "1e3d5b76-7ace-11e7-9b9f-0242ac110003",
            "retailer": "walmart",
            "date_start": "2019-05-24",
            "date_end": "2019-05-25"
        }

        celery_task = main_task.apply_async(args=(Product.count_by_store_task,
                                                  params))
        print("Submitted Task: ", celery_task.id)
        # Get the task from the celery task
        time.sleep(2)
        task = Task(celery_task.id)
        print('Created task instance!')

        # Check result of task
        while task.is_running():
            print("Waiting for task to finish")
            print(task.task_id)
            print(task.progress)
            print(task.status)
            time.sleep(1)

        prog = task.status['progress']
        print("Final progress: {}".format(prog))
        print("Result keys: {} ".format(list(task.result.keys())))
        self.assertEqual(prog, 100)