Untitled
unknown
python
2 years ago
2.3 kB
11
Indexable
import allure
from datetime import datetime, timedelta
# Constants
PVZ_NAME = "Пункт выдачи OZON г. Москва, наб. Пресненская, д. 10 блок C"
ADDRESS_STRING = 'г. Москва, наб. Пресненская, д. 10 блок C'
FOOT_DIMENSION = Dimensions(5000, 750, 450, 380)
DELIVERY_TYPE = 'PVZ'
DELIVERY_SCHEMA = 'FBS'
def create_posting(api, address, item_kiz, item_not_kiz, timeslot, wh):
return Posting(address, [item_kiz, item_not_kiz], timeslot, wh, delivery_type=DELIVERY_TYPE, delivery_schema=DELIVERY_SCHEMA)
def create_order(postings, wh, user_client_id):
return KrakenOrder(postings=postings, warehouse=wh, client_id=user_client_id, delivery_type=DELIVERY_TYPE, delivery_schema=DELIVERY_SCHEMA)
def update_posting_timeslot(db, postings):
for posting in postings:
new_timeslot = (datetime.now() + timedelta(hours=2)).strftime("%Y-%m-%d %H:00:00.") + '000'
db.rezon.update_posting_timeslot_by_posting_number(posting.number, new_timeslot)
def test_pvz_mono_packing(api, timeslotinfo, db, kraken_order_manager, user_client_id):
with allure.step('cоздаем постинги'):
wh = Warehouse_9833
address = Address(ADDRESS_STRING)
timeslot = timeslotinfo.get_time_slots_for_pvz(PVZ_NAME).get_ts_that_start_after_minutes(10).earliest
item_kiz_id = int(db.rezon.get_kiz_items_on_wh_by_rezonwh_id(wh.rezon_id)[3]["sku"])
item_not_kiz_id = int(db.rezon.get_not_kiz_items_on_wh_by_rezonwh_id(wh.rezon_id)[6]["sku"])
item_kiz = Item(item_kiz_id, 3, FOOT_DIMENSION, delivery_schema=DELIVERY_SCHEMA)
item_not_kiz = Item(item_not_kiz_id, 3, FOOT_DIMENSION, delivery_schema=DELIVERY_SCHEMA)
postings = []
orders = []
for item1, item2 in [(item_kiz, item_not_kiz), (item_kiz, None), (None, item_not_kiz)]:
posting = create_posting(api, address, item1, item2, timeslot, wh)
postings.append(posting)
order = create_order([posting], wh, user_client_id)
orders.append(order)
for order in orders:
order = kraken_order_manager.create_and_pay_order(order, check_pay=False)
update_posting_timeslot(db, order.postings)
Editor is loading...