Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
3.6 kB
0
Indexable
Never
from Utils.KrakenOrderHelper.express_whs import Warehouse_49113
from tests.batching.regress.orders_settings import orders_without_bags, orders_with_bags
from tests.batching.regress.utils import wait_for_batching_task, get_timeslots, delivery_type_to_sort_variant

item_qty = 1
postings_qty = 3
wh = Warehouse_49113


def check_posting_batches(orders_results, db, sort_variant_ids, item_id):
    postings = 0
    posting_batches = []
    for order_result in orders_results:
        for posting in order_result:
            postings += 1
            print(posting["ID"])
            batching_task = wait_for_batching_task(db, posting["ID"])
            assert batching_task
            res = db.rezon.get_posting_batch_by_posting_id(posting["ID"])[0]
            sort_variant_name = delivery_type_to_sort_variant[posting["delivery_type"]]
            expected_sort_method_id = sort_variant_ids[sort_variant_name]
            store_task_items = db.rezon.get_items_in_store_task(batching_task[0]['ID'])
            assert len(store_task_items) == 1
            assert store_task_items[0]['ItemID'] == item_id
            assert res[
                       "SortMethodID"] == expected_sort_method_id, f"SortMethodID не соответствует {posting['delivery_type']}"
            posting_batches.append(batching_task[0]["PostingBatchID"])
    assert len(set(posting_batches)) == postings


class TestRegressBatching:
    def test_positive_path_without_bags(api, db, create_order, random_client_user_id, get_timeslot_id,
                                        get_ts_for_pvz,
                                        check_sort_variants):
        sort_variant_ids = check_sort_variants(wh)
        item_id = db.rezon.get_supermarket_items_on_wh_by_rezonwh_id(wh.rezon_id)[3]["itemid"]  # чтобы не взять пакеты
        day_to_day_timeslot, express_timeslot, pvz_timeslot = get_timeslots(wh, get_timeslot_id, get_ts_for_pvz)
        orders_results = orders_without_bags(create_order,
                                             item_id,
                                             wh.rezon_id,
                                             random_client_user_id,
                                             pvz_timeslot,
                                             day_to_day_timeslot,
                                             express_timeslot,
                                             item_qty,
                                             postings_qty)
        check_posting_batches(orders_results, db, sort_variant_ids, item_id)

    def test_positive_path_with_bags(api, db, create_order, random_client_user_id, get_timeslot_id,
                                     get_ts_for_pvz,
                                     check_sort_variants):
        sort_variant_ids = check_sort_variants(wh)
        day_to_day_timeslot, express_timeslot, pvz_timeslot = get_timeslots(wh, get_timeslot_id, get_ts_for_pvz)
        item_id = db.rezon.get_supermarket_items_on_wh_by_rezonwh_id(wh.rezon_id)[3]["itemid"]  # чтобы не взять пакеты
        orders_results = orders_with_bags(create_order,
                                          item_id,
                                          wh.rezon_id,
                                          random_client_user_id,
                                          day_to_day_timeslot,
                                          express_timeslot,
                                          item_qty,
                                          postings_qty)
        check_posting_batches(orders_results, db, sort_variant_ids, item_id)
Leave a Comment