first commit
This commit is contained in:
105
service_app_test/test_application/evyos/decision_book_items.py
Normal file
105
service_app_test/test_application/evyos/decision_book_items.py
Normal file
@@ -0,0 +1,105 @@
|
||||
from test_application.evyos.bases import requester, active_and_confirmed
|
||||
from test_application.evyos.datas.get_occupants_codes import get_occupants_types
|
||||
from test_application.evyos.datas.get_type_codes import get_type_codes_key_and_class
|
||||
|
||||
|
||||
decision_book_items_dict = lambda token, item_comment, info_type_uu_id, unit_price, is_fixed, st, ed: {
|
||||
"token": token,
|
||||
"item_comment": f"Test {item_comment}",
|
||||
"info_type_uu_id": info_type_uu_id,
|
||||
"unit_price": unit_price,
|
||||
"unit_price_is_fixed": is_fixed,
|
||||
"debit_start_date": st,
|
||||
"debit_end_date": ed,
|
||||
**active_and_confirmed,
|
||||
}
|
||||
|
||||
|
||||
def create_decision_book_items(decision_book_items):
|
||||
response = requester.post(
|
||||
endpoint="/build/decision_book/items/create",
|
||||
data=decision_book_items,
|
||||
)
|
||||
print("text", response.text)
|
||||
print("json", response.json())
|
||||
return response.json()
|
||||
|
||||
|
||||
def send_invitation_to_building_residents(send_invitation_dict):
|
||||
response = requester.post(
|
||||
endpoint="/build/decision_book/invite/create",
|
||||
data=send_invitation_dict,
|
||||
)
|
||||
print("text", response.text)
|
||||
print("json", response.json())
|
||||
return response.json()
|
||||
|
||||
|
||||
def assign_people_to_pre_or_wrt(
|
||||
person_uu_id: str, manager_token: str, occupant_code: str
|
||||
):
|
||||
response = requester.post(
|
||||
endpoint="/build/decision_book/invitations/assign",
|
||||
data={
|
||||
"token": manager_token,
|
||||
"build_living_space_uu_id": person_uu_id,
|
||||
"occupant_type_uu_id": get_occupants_types(occupant_code=occupant_code)[
|
||||
"data"
|
||||
]["uu_id"],
|
||||
},
|
||||
)
|
||||
print("text", response.text)
|
||||
print("json", response.json())
|
||||
return response.json()
|
||||
|
||||
|
||||
def collect_invitation_to_building_residents(
|
||||
attended_dict_list: list, attend_count: int
|
||||
):
|
||||
for cnt, attended_token in enumerate(attended_dict_list):
|
||||
attended_dict = {"token": attended_token, "is_attend": False}
|
||||
if cnt + 1 < attend_count:
|
||||
attended_dict["is_attend"] = True
|
||||
response = requester.post(
|
||||
endpoint="/build/decision_book/invitations/attend",
|
||||
data=attended_dict,
|
||||
)
|
||||
print("text", response.text)
|
||||
print("json", response.json())
|
||||
return
|
||||
|
||||
|
||||
def create_decision_book_items_with_occupant_user(
|
||||
writers_token: str, unit_price: float, is_fixed: bool, info_type_uu_id: str,
|
||||
start_date: str = None, end_date: str = None
|
||||
):
|
||||
print("create_decision_book_items_with_occupant_user : ", writers_token)
|
||||
list_of_items = [
|
||||
decision_book_items_dict(
|
||||
token=writers_token,
|
||||
item_comment="This is an item debit for test purposes",
|
||||
info_type_uu_id=info_type_uu_id,
|
||||
unit_price=unit_price,
|
||||
is_fixed=is_fixed,
|
||||
st=start_date,
|
||||
ed=end_date
|
||||
),
|
||||
]
|
||||
for item in list_of_items:
|
||||
print("item", item)
|
||||
create_decision_book_items(item)
|
||||
return
|
||||
|
||||
|
||||
def run_decision_book_items(
|
||||
writers_token, unit_price, info_type_uu_id, is_fixed, start_date=None, end_date=None
|
||||
):
|
||||
if start_date and end_date:
|
||||
create_decision_book_items_with_occupant_user(
|
||||
writers_token=writers_token, unit_price=unit_price, is_fixed=is_fixed, info_type_uu_id=info_type_uu_id,
|
||||
start_date=start_date, end_date=end_date
|
||||
)
|
||||
else:
|
||||
create_decision_book_items_with_occupant_user(
|
||||
writers_token=writers_token, unit_price=unit_price, is_fixed=is_fixed, info_type_uu_id=info_type_uu_id,
|
||||
)
|
||||
Reference in New Issue
Block a user