alchemy flush and save functions updated
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from random import randint
|
||||
from faker import Faker
|
||||
|
||||
from test_application.evyos.bases import requester, active_and_confirmed
|
||||
from test_application.evyos.datas.company_employee_data import list_options
|
||||
from test_application.evyos.datas.get_building_types import list_building_types
|
||||
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
|
||||
from service_app_test.test_application.evyos.datas.company_employee_data import list_options
|
||||
from service_app_test.test_application.evyos.datas.get_building_types import list_building_types
|
||||
from service_app_test.test_application.evyos.datas.get_occupants_codes import get_occupants_types
|
||||
from service_app_test.test_application.evyos.datas.get_type_codes import get_type_codes_key_and_class
|
||||
from service_app_test.bases import active_and_confirmed
|
||||
|
||||
|
||||
fake = Faker()
|
||||
|
||||
@@ -55,7 +56,7 @@ build_living_space = lambda build_part_uu_id, life_person_uu_id, occupant_type_u
|
||||
}
|
||||
|
||||
|
||||
def create_build_parts(build_uu_id, count: int = 1):
|
||||
def create_build_parts(requester, build_uu_id, count: int = 1):
|
||||
flat_type = list_building_types(type_code="DAIRE")
|
||||
flat_type_uu_id = flat_type["data"][0]["uu_id"]
|
||||
directions = get_type_codes_key_and_class(class_name="Directions", key_name="NN")
|
||||
@@ -76,7 +77,7 @@ def create_build_parts(build_uu_id, count: int = 1):
|
||||
# return response.json()
|
||||
|
||||
|
||||
def create_post_code(post_code):
|
||||
def create_post_code(post_code, requester):
|
||||
print("post_code", post_code)
|
||||
post_code_response = requester.post(
|
||||
endpoint="/postcode/create",
|
||||
@@ -87,7 +88,7 @@ def create_post_code(post_code):
|
||||
return
|
||||
|
||||
|
||||
def create_addresses(address):
|
||||
def create_addresses(address, requester):
|
||||
address_response = requester.post(
|
||||
endpoint="/address/create",
|
||||
data=address,
|
||||
@@ -97,7 +98,7 @@ def create_addresses(address):
|
||||
return
|
||||
|
||||
|
||||
def create_build_with_address_uu_id(address_dict_with_uu_id):
|
||||
def create_build_with_address_uu_id(address_dict_with_uu_id, requester):
|
||||
response = requester.post(
|
||||
endpoint="/building/build/create",
|
||||
data={**address_dict_with_uu_id, "build_number": "11"},
|
||||
@@ -107,7 +108,7 @@ def create_build_with_address_uu_id(address_dict_with_uu_id):
|
||||
return response.json()
|
||||
|
||||
|
||||
def create_build_living_space(living_space_dict):
|
||||
def create_build_living_space(living_space_dict, requester):
|
||||
response = requester.post(
|
||||
endpoint="/building/living_space/create",
|
||||
data=living_space_dict,
|
||||
@@ -117,7 +118,7 @@ def create_build_living_space(living_space_dict):
|
||||
return response.json()
|
||||
|
||||
|
||||
def search_street(search_text):
|
||||
def search_street(search_text, requester):
|
||||
response = requester.post(
|
||||
endpoint="/address/search",
|
||||
data={
|
||||
@@ -141,7 +142,7 @@ def search_street(search_text):
|
||||
return street_data["AddressStreet.uu_id"]
|
||||
|
||||
|
||||
def list_post_codes():
|
||||
def list_post_codes(requester):
|
||||
post_code_response = requester.post(
|
||||
endpoint="/postcode/list",
|
||||
data=list_options,
|
||||
@@ -151,7 +152,7 @@ def list_post_codes():
|
||||
return post_code_response.json()
|
||||
|
||||
|
||||
def list_addresses():
|
||||
def list_addresses(requester):
|
||||
address_response = requester.post(
|
||||
endpoint="/address/list",
|
||||
data=list_options,
|
||||
@@ -161,7 +162,7 @@ def list_addresses():
|
||||
return address_response.json()
|
||||
|
||||
|
||||
def list_building(query=None):
|
||||
def list_building(requester, query=None):
|
||||
query_options = list_options
|
||||
if query:
|
||||
query_options["query"] = query
|
||||
@@ -171,7 +172,7 @@ def list_building(query=None):
|
||||
return response.json()
|
||||
|
||||
|
||||
def list_build_living_space():
|
||||
def list_build_living_space(requester):
|
||||
response = requester.post(
|
||||
endpoint="/building/living_space/list",
|
||||
data=list_options,
|
||||
@@ -181,7 +182,7 @@ def list_build_living_space():
|
||||
return response.json()
|
||||
|
||||
|
||||
def list_building_parts(query: dict = None):
|
||||
def list_building_parts(requester,query: dict = None):
|
||||
query_dict = query
|
||||
if not query:
|
||||
query_dict = {"part_code__contains": ":"}
|
||||
@@ -196,64 +197,69 @@ def list_building_parts(query: dict = None):
|
||||
|
||||
|
||||
def create_property_owner(
|
||||
build_part_uu_id, person_uu_id, occupant_type_flat_owner_uu_id
|
||||
build_part_uu_id, person_uu_id, occupant_type_flat_owner_uu_id, requester
|
||||
):
|
||||
return create_build_living_space(
|
||||
living_space_dict=build_living_space(
|
||||
build_part_uu_id=build_part_uu_id,
|
||||
life_person_uu_id=person_uu_id,
|
||||
occupant_type_uu_id=occupant_type_flat_owner_uu_id,
|
||||
)
|
||||
),
|
||||
requester=requester,
|
||||
)
|
||||
|
||||
|
||||
def create_property_tenant(
|
||||
build_part_uu_id, person_uu_id, occupant_type_flat_tenant_uu_id
|
||||
build_part_uu_id, person_uu_id, occupant_type_flat_tenant_uu_id, requester
|
||||
):
|
||||
return create_build_living_space(
|
||||
living_space_dict=build_living_space(
|
||||
build_part_uu_id=build_part_uu_id,
|
||||
life_person_uu_id=person_uu_id,
|
||||
occupant_type_uu_id=occupant_type_flat_tenant_uu_id,
|
||||
)
|
||||
),
|
||||
requester=requester,
|
||||
)
|
||||
|
||||
|
||||
def create_property_resident(
|
||||
build_part_uu_id, person_uu_id, occupant_type_flat_resident_uu_id
|
||||
build_part_uu_id, person_uu_id, occupant_type_flat_resident_uu_id, requester
|
||||
):
|
||||
return create_build_living_space(
|
||||
living_space_dict=build_living_space(
|
||||
build_part_uu_id=build_part_uu_id,
|
||||
life_person_uu_id=person_uu_id,
|
||||
occupant_type_uu_id=occupant_type_flat_resident_uu_id,
|
||||
)
|
||||
),
|
||||
requester=requester,
|
||||
)
|
||||
|
||||
|
||||
def create_property_observer(build_part_uu_id, person_uu_id):
|
||||
def create_property_observer(build_part_uu_id, person_uu_id, requester):
|
||||
return create_build_living_space(
|
||||
living_space_dict=build_living_space(
|
||||
build_part_uu_id=build_part_uu_id,
|
||||
life_person_uu_id=person_uu_id,
|
||||
occupant_type_uu_id=None,
|
||||
)
|
||||
),
|
||||
requester=requester,
|
||||
)
|
||||
|
||||
|
||||
def create_occupant_build_manager(
|
||||
build_part_uu_id, person_uu_id, occupant_type_flat_manager_uu_id
|
||||
build_part_uu_id, person_uu_id, occupant_type_flat_manager_uu_id, requester
|
||||
):
|
||||
return create_build_living_space(
|
||||
living_space_dict=build_living_space(
|
||||
build_part_uu_id=build_part_uu_id,
|
||||
life_person_uu_id=person_uu_id,
|
||||
occupant_type_uu_id=occupant_type_flat_manager_uu_id,
|
||||
)
|
||||
),
|
||||
requester=requester,
|
||||
)
|
||||
|
||||
|
||||
def get_random_people_list():
|
||||
def get_random_people_list(requester):
|
||||
# person_uu_id : 2d5dac99-c445-44fc-a0a5-de97ec65781a is a tenant and lives in the build part as PL and PT
|
||||
random_user_list_response = requester.post(
|
||||
data={
|
||||
@@ -277,7 +283,7 @@ def get_random_people_list():
|
||||
|
||||
|
||||
def assign_random_people_to_build_parts(
|
||||
list_of_building_parts, list_of_random_people, occupant_dict, build_uu_id
|
||||
list_of_building_parts, list_of_random_people, occupant_dict, build_uu_id, requester
|
||||
):
|
||||
|
||||
part_counter = 0
|
||||
@@ -286,7 +292,7 @@ def assign_random_people_to_build_parts(
|
||||
uu_id_occupant_type_flat_manager = occupant_dict["occupant_type_flat_manager"]
|
||||
uu_id_occupant_type_flat_resident = occupant_dict["occupant_type_flat_resident"]
|
||||
|
||||
man_room = list_building_parts(query={"part_no": "0", "build_uu_id": build_uu_id})
|
||||
man_room = list_building_parts(query={"part_no": "0", "build_uu_id": build_uu_id}, requester=requester)
|
||||
man_room_uu_id = man_room["data"][0]["uu_id"]
|
||||
|
||||
for i in range(len(list_of_random_people)):
|
||||
@@ -301,6 +307,7 @@ def assign_random_people_to_build_parts(
|
||||
build_part_uu_id=selected_build_part_uu_id,
|
||||
person_uu_id=list_of_random_people[i - 1]["uu_id"],
|
||||
occupant_type_flat_owner_uu_id=uu_id_occupant_type_flat_owner,
|
||||
requester=requester
|
||||
)
|
||||
|
||||
# Property Tenant
|
||||
@@ -308,6 +315,7 @@ def assign_random_people_to_build_parts(
|
||||
build_part_uu_id=selected_build_part_uu_id,
|
||||
person_uu_id=list_of_random_people[i]["uu_id"],
|
||||
occupant_type_flat_tenant_uu_id=uu_id_occupant_type_flat_tenant,
|
||||
requester=requester
|
||||
)
|
||||
|
||||
# Property Tenant Living Space Occupant
|
||||
@@ -315,6 +323,7 @@ def assign_random_people_to_build_parts(
|
||||
build_part_uu_id=selected_build_part_uu_id,
|
||||
person_uu_id=list_of_random_people[i]["uu_id"],
|
||||
occupant_type_flat_resident_uu_id=uu_id_occupant_type_flat_resident,
|
||||
requester=requester
|
||||
)
|
||||
|
||||
if i == 1:
|
||||
@@ -322,11 +331,12 @@ def assign_random_people_to_build_parts(
|
||||
build_part_uu_id=man_room_uu_id,
|
||||
person_uu_id=list_of_random_people[i]["uu_id"],
|
||||
occupant_type_flat_manager_uu_id=uu_id_occupant_type_flat_manager,
|
||||
requester=requester
|
||||
)
|
||||
|
||||
|
||||
def run_address_to_building():
|
||||
street_uu_id = search_street("Reşat Nuri")
|
||||
def run_address_to_building(requester):
|
||||
street_uu_id = search_street("Reşat Nuri", requester=requester)
|
||||
|
||||
occupant_type_flat_owner = get_occupants_types(occupant_code="FL-OWN")
|
||||
occupant_type_flat_tenant = get_occupants_types(occupant_code="FL-TEN")
|
||||
@@ -340,11 +350,11 @@ def run_address_to_building():
|
||||
occupant_type_flat_resident=occupant_type_flat_resident["data"]["uu_id"],
|
||||
)
|
||||
|
||||
create_post_code(post_code=post_code_dict(street_uu_id))
|
||||
selected_post_code_uu_id = list_post_codes()["data"][0]["uu_id"]
|
||||
create_post_code(post_code=post_code_dict(street_uu_id), requester=requester)
|
||||
selected_post_code_uu_id = list_post_codes(requester=requester)["data"][0]["uu_id"]
|
||||
|
||||
create_addresses(address=address_dict(selected_post_code_uu_id))
|
||||
selected_address_uu_id = list_addresses()["data"][0]["uu_id"]
|
||||
create_addresses(address=address_dict(selected_post_code_uu_id), requester=requester)
|
||||
selected_address_uu_id = list_addresses(requester=requester)["data"][0]["uu_id"]
|
||||
|
||||
build_type_response = list_building_types(type_code="apt")
|
||||
build_type_uu_id_ = build_type_response["data"][0]["uu_id"]
|
||||
@@ -352,14 +362,15 @@ def run_address_to_building():
|
||||
build_dict(
|
||||
address_uu_id=selected_address_uu_id,
|
||||
build_type_uu_id=build_type_uu_id_,
|
||||
)
|
||||
),
|
||||
requester=requester
|
||||
)
|
||||
|
||||
selected_build_uu_id = list_building()["data"][0]["uu_id"]
|
||||
create_build_parts(selected_build_uu_id, count=21)
|
||||
selected_build_uu_id = list_building(requester=requester)["data"][0]["uu_id"]
|
||||
create_build_parts(build_uu_id=selected_build_uu_id, count=21, requester=requester)
|
||||
|
||||
random_people_list = get_random_people_list()
|
||||
building_parts_list = list_building_parts()["data"]
|
||||
random_people_list = get_random_people_list(requester=requester)
|
||||
building_parts_list = list_building_parts(requester=requester)["data"]
|
||||
print("building_parts_list", len(building_parts_list))
|
||||
|
||||
assign_random_people_to_build_parts(
|
||||
@@ -367,5 +378,6 @@ def run_address_to_building():
|
||||
list_of_building_parts=building_parts_list,
|
||||
occupant_dict=occupant_type_dict,
|
||||
build_uu_id=selected_build_uu_id,
|
||||
requester=requester
|
||||
)
|
||||
print("list_build_living_space", list_build_living_space())
|
||||
print("list_build_living_space", list_build_living_space(requester=requester))
|
||||
|
||||
Reference in New Issue
Block a user