first commit

This commit is contained in:
2024-11-07 17:44:29 +03:00
commit 643d6d8f65
247 changed files with 420800 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
# Git
.git
.gitignore
.gitattributes
# CI
.codeclimate.yml
.travis.yml
.taskcluster.yml
# Docker
docker-compose.yml
service_app/Dockerfile
.docker
.dockerignore
# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
service_app/env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Virtual environment
service_app/.env
.venv/
venv/
# PyCharm
.idea
# Python mode for VIM
.ropeproject
**/.ropeproject
# Vim swap files
**/*.swp
# VS Code
.vscode/
test_application/

162
service_app_test/.gitignore vendored Normal file
View File

@@ -0,0 +1,162 @@
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.idea/
.Python
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
service_app/.env
.venv
service_app/env/
venv/
service_app/env/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

View File

@@ -0,0 +1,24 @@
FROM python:3.12-slim-bookworm
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
COPY ../service_app_test/requirements.txt .
RUN uv venv
RUN uv pip install -r requirements.txt
COPY ../service_app_test ./service_app_test
WORKDIR /service_app_test
CMD ["uv", "run", "runner.py"]
# Old File
#FROM python:3.10
#RUN pip install --upgrade pip
#RUN pip install --no-cache-dir --upgrade -r requirements.txt
#CMD ["python", "-m", "app"]

View File

View File

@@ -0,0 +1,3 @@
arrow
faker
requests

View File

@@ -0,0 +1,4 @@
if __name__ == "__main__":
print("service_app_test is running")

View File

@@ -0,0 +1,10 @@
Step by step to create the api.
1. Create Company -> Employee : company_employee.py
2. Bind Employee to People : employee_people.py
3. Address -> Building : address_building.py
4. Decision Book -> Decision Book Item : decision_book.py

View File

@@ -0,0 +1,371 @@
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
fake = Faker()
post_code_dict = lambda uu_id_street: {
"post_code": "06690",
"street_uu_id": uu_id_street,
**active_and_confirmed,
}
address_dict = lambda post_code_uu_id: {
"post_code_uu_id": post_code_uu_id,
"comment_address": "Reşat Nuri Cad No 11",
"letter_address": "Reşat Nuri Cad No 11 ÇANKAYA ANKARA TÜRKİYE",
"short_letter_address": "Reşat Nuri Cad No 11 ÇANKAYA ANKARA TÜRKİYE",
"build_number": "11",
**active_and_confirmed,
}
build_dict = lambda address_uu_id, build_type_uu_id: {
"gov_address_code": f"1231231231{randint(0,99)}",
"build_name": fake.street_name(),
"build_types_uu_id": build_type_uu_id,
"max_floor": randint(0, 99),
"underground_floor": "0",
"address_uu_id": address_uu_id,
"build_date": "1970-02-01",
"decision_period_date": "1970-07-01",
**active_and_confirmed,
}
build_part_dict = lambda build_uu_id, count, flat_type_uu_id, directions_uu_id: {
"build_uu_id": build_uu_id,
"address_gov_code": f"1231231231{randint(0,99)}",
"part_no": count + 1,
"part_level": count + 1,
"build_part_type_uu_id": flat_type_uu_id,
"part_gross_size": randint(141, 180),
"part_net_size": randint(80, 140),
"default_accessory": "Klima",
"human_livable": True,
"part_direction_uu_id": directions_uu_id,
**active_and_confirmed,
}
build_living_space = lambda build_part_uu_id, life_person_uu_id, occupant_type_uu_id: {
"build_parts_uu_id": build_part_uu_id,
"person_uu_id": life_person_uu_id,
"occupant_type_uu_id": occupant_type_uu_id,
**active_and_confirmed,
}
def create_build_parts(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")
directions_uu_id = directions["data"]["uu_id"]
for count_ in range(count):
response = requester.post(
endpoint="/building/parts/create",
data=build_part_dict(
build_uu_id=build_uu_id,
count=count_,
flat_type_uu_id=flat_type_uu_id,
directions_uu_id=directions_uu_id,
),
)
# print("text", response.text)
# print("json", response.json())
# return response.json()
def create_post_code(post_code):
print("post_code", post_code)
post_code_response = requester.post(
endpoint="/postcode/create",
data=post_code,
)
print("text", post_code_response.text)
print("json", post_code_response.json())
return
def create_addresses(address):
address_response = requester.post(
endpoint="/address/create",
data=address,
)
print("text", address_response.text)
print("json", address_response.json())
return
def create_build_with_address_uu_id(address_dict_with_uu_id):
response = requester.post(
endpoint="/building/build/create",
data={**address_dict_with_uu_id, "build_number": "11"},
)
print("text", response.text)
print("json", response.json())
return response.json()
def create_build_living_space(living_space_dict):
response = requester.post(
endpoint="/building/living_space/create",
data=living_space_dict,
)
# print("text", response.text)
# print("json", response.json())
return response.json()
def search_street(search_text):
response = requester.post(
endpoint="/address/search",
data={
"search": search_text,
"list_options": {
"page": 1,
"size": 30,
},
},
)
print("text", response.text)
print("json", response.json())
for street_data in response.json().get("data"):
condition_of_street = (
street_data["AddressCity.city_name"] == "ANKARA"
and street_data["AddressDistrict.district_name"] == "ÇANKAYA"
)
if condition_of_street:
print("street_uu_id", street_data["AddressStreet.uu_id"])
return street_data["AddressStreet.uu_id"]
def list_post_codes():
post_code_response = requester.post(
endpoint="/postcode/list",
data=list_options,
)
print("text", post_code_response.text)
print("json", post_code_response.json())
return post_code_response.json()
def list_addresses():
address_response = requester.post(
endpoint="/address/list",
data=list_options,
)
print("text", address_response.text)
print("json", address_response.json())
return address_response.json()
def list_building(query=None):
query_options = list_options
if query:
query_options["query"] = query
response = requester.post(endpoint="/building/build/list", data=query_options)
print("text", response.text)
print("json", response.json())
return response.json()
def list_build_living_space():
response = requester.post(
endpoint="/building/living_space/list",
data=list_options,
)
print("text", response.text)
print("json", response.json())
return response.json()
def list_building_parts(query: dict = None):
query_dict = query
if not query:
query_dict = {"part_code__contains": ":"}
response = requester.post(
endpoint="/building/parts/list",
data={**list_options, "query": query_dict},
)
print("text", response.text)
print("json", response.json())
return response.json()
def create_property_owner(
build_part_uu_id, person_uu_id, occupant_type_flat_owner_uu_id
):
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,
)
)
def create_property_tenant(
build_part_uu_id, person_uu_id, occupant_type_flat_tenant_uu_id
):
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,
)
)
def create_property_resident(
build_part_uu_id, person_uu_id, occupant_type_flat_resident_uu_id
):
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,
)
)
def create_property_observer(build_part_uu_id, person_uu_id):
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,
)
)
def create_occupant_build_manager(
build_part_uu_id, person_uu_id, occupant_type_flat_manager_uu_id
):
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,
)
)
def get_random_people_list():
# 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={
"page": 1,
"size": 70,
"query": {"created_by": None, "email__contains": "@example."},
},
endpoint="/user/list",
).json()
random_user_list = [
str(user["uu_id"]) for user in random_user_list_response["data"]
]
print("random_user_list", random_user_list)
random_people_list_response = requester.post(
data={"page": 1, "size": 70, "query": {"user_uu_id_list": random_user_list}},
endpoint="/user/list",
).json()
return random_people_list_response["data"]
def assign_random_people_to_build_parts(
list_of_building_parts, list_of_random_people, occupant_dict, build_uu_id
):
part_counter = 0
uu_id_occupant_type_flat_owner = occupant_dict["occupant_type_flat_owner"]
uu_id_occupant_type_flat_tenant = occupant_dict["occupant_type_flat_tenant"]
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_uu_id = man_room["data"][0]["uu_id"]
for i in range(len(list_of_random_people)):
if i % 2 == 1 and not i == 0:
if part_counter == len(list_of_building_parts):
break
selected_build_part_uu_id = list_of_building_parts[part_counter]["uu_id"]
part_counter += 1
# Property Owner
create_property_owner(
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,
)
# Property Tenant
create_property_tenant(
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,
)
# Property Tenant Living Space Occupant
create_property_resident(
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,
)
if i == 1:
create_occupant_build_manager(
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,
)
def run_address_to_building():
street_uu_id = search_street("Reşat Nuri")
occupant_type_flat_owner = get_occupants_types(occupant_code="FL-OWN")
occupant_type_flat_tenant = get_occupants_types(occupant_code="FL-TEN")
occupant_type_flat_manager = get_occupants_types(occupant_code="BU-MNG")
occupant_type_flat_resident = get_occupants_types(occupant_code="FL-RES")
occupant_type_dict = dict(
occupant_type_flat_owner=occupant_type_flat_owner["data"]["uu_id"],
occupant_type_flat_tenant=occupant_type_flat_tenant["data"]["uu_id"],
occupant_type_flat_manager=occupant_type_flat_manager["data"]["uu_id"],
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_addresses(address=address_dict(selected_post_code_uu_id))
selected_address_uu_id = list_addresses()["data"][0]["uu_id"]
build_type_response = list_building_types(type_code="apt")
build_type_uu_id_ = build_type_response["data"][0]["uu_id"]
create_build_with_address_uu_id(
build_dict(
address_uu_id=selected_address_uu_id,
build_type_uu_id=build_type_uu_id_,
)
)
selected_build_uu_id = list_building()["data"][0]["uu_id"]
create_build_parts(selected_build_uu_id, count=21)
random_people_list = get_random_people_list()
building_parts_list = list_building_parts()["data"]
print("building_parts_list", len(building_parts_list))
assign_random_people_to_build_parts(
list_of_random_people=random_people_list,
list_of_building_parts=building_parts_list,
occupant_dict=occupant_type_dict,
build_uu_id=selected_build_uu_id,
)
print("list_build_living_space", list_build_living_space())

View File

@@ -0,0 +1,2 @@
from test_application.evyos.bases import requester
from test_application.evyos.datas.company_employee_data import list_options

View File

@@ -0,0 +1,144 @@
import requests
from api_configs import Auth
active_and_confirmed = dict(
created_by="System",
confirmed_by="System",
is_confirmed=True,
active=True,
deleted=False,
is_notification_send=True,
)
class RequestToApi:
def __init__(self, base_url=None):
self.base_url = base_url or "http://0.0.0.0:41575/"
self.headers = {
"domain": "evyos.com.tr",
"Content-Type": "application/json",
"Accept": "application/json",
}
def set_access_token(self, access_token):
self.headers[Auth.ACCESS_TOKEN_TAG] = access_token
def url(self, endpoint):
return self.base_url + endpoint
def post(self, data, endpoint):
response = requests.post(self.url(endpoint), headers=self.headers, json=data)
return response
def get(self, endpoint):
print("url", self.url(endpoint))
response = requests.get(self.url(endpoint), headers=self.headers)
return response
def patch(self, data, endpoint):
response = requests.patch(self.url(endpoint), headers=self.headers, json=data)
return response
class FilterObject:
def __init__(
self,
page=None,
size=None,
order_field=None,
order_type=None,
include_joins=None,
query=None,
):
self.page = page or 1
self.size = size or 10
self.order_field = order_field or "id"
self.order_type = order_type or "asc"
self.include_joins = include_joins or []
self.query = query or {}
def dump(self):
return dict(
page=self.page,
size=self.size,
order_field=self.order_field,
order_type=self.order_type,
include_joins=list(self.include_joins),
query=dict(self.query),
)
def login_via_email_and_password(
login_data, is_password_valid=True, selection_list: list = None
):
if not is_password_valid:
if not login_data.get("password_token"):
raise Exception("Password token is not found")
change_password_with_token(password_token=login_data.get("password_token"))
login_dict = requester.post(endpoint="authentication/login", data=login_data)
print("login_dict", login_dict.text)
login_dict = login_dict.json()
content = login_dict
access_token = content.get("access_token")
refresh_token = content.get("refresh_token")
access_object = content.get("access_object")
if not access_object:
raise Exception("Access object is not found")
companies_uu_id_list = None
if access_object.get("user_type") == "employee":
companies_uu_id_list = access_object.get("companies_uu_id_list")
elif access_object.get("user_type") == "occupant":
companies_uu_id_list = access_object.get("available_occupants")
# Todo Create Company and assign bulk to Duty2Company
if not selection_list and not access_object.get("user_type") == "employee":
print("Please select a company and an occupant")
print(companies_uu_id_list)
exit()
requester.set_access_token(access_token)
if access_object.get("user_type") == "employee":
uu_id = companies_uu_id_list[0]
refresh_company = requester.post(
endpoint="authentication/select", data={"company_uu_id": uu_id}
)
return uu_id
elif access_object.get("user_type") == "occupant":
occupants = companies_uu_id_list[str(selection_list[0])]
occupant_uu_id = None
for occupant in occupants:
if occupant == str(selection_list[1]):
occupant_uu_id = occupant
break
return_dict = {
"occupant_uu_id": occupant_uu_id,
"build_part_uu_id": str(selection_list[0]),
}
refresh_company = requester.post(
endpoint="authentication/select", data=return_dict
)
return return_dict
def change_password_with_token(password_token):
data_dict = {
"password_token": password_token,
"password": "string",
"re_password": "string",
}
if password_token:
response = requester.post(
data=data_dict, endpoint="authentication/create_password"
)
print(response.json())
requester = RequestToApi()

View File

@@ -0,0 +1,189 @@
from test_application.evyos.bases import (
requester,
# select_company_uu_id,
active_and_confirmed,
)
from test_application.evyos.people import (
create_random_person,
create_random_user,
create_random_occupant_user,
)
from test_application.evyos.datas.company_employee_data import (
departments,
duties,
staffs,
)
print("Program up and running **-------------------------------------")
def create_department_via_list(list_of_departments):
for department in list_of_departments:
request_department = requester.post(
data={
**department,
**active_and_confirmed,
},
endpoint="department/create",
)
print(request_department.json())
def create_duty_via_list(list_of_duties):
for duty in list_of_duties:
duty_dict = {
"duty_name": duty["duty_name"],
"duty_code": duty["duty_code"],
"duty_description": duty["duty_description"],
**active_and_confirmed,
}
request_duty = requester.post(data=duty_dict, endpoint="duty/create")
print(request_duty.json())
def create_duties_via_list(list_of_duties, company_uu_id):
for duty in list_of_duties:
department_response = requester.post(
endpoint="department/list",
data={"query": dict(department_name=duty["department_name"])},
)
selected_department = department_response.json()["data"][0]["uu_id"]
duty_response = requester.post(
endpoint="duty/list",
data={"query": dict(duty_name=duty["duty_name"])},
)
selected_duties = duty_response.json()["data"][0]["uu_id"]
duty_dict = {
"department_uu_id": selected_department,
"duties_uu_id": selected_duties,
**active_and_confirmed,
}
request_duty = requester.post(data=duty_dict, endpoint="duties/create")
print(request_duty.json())
requester.post(
endpoint="authentication/select", data={"company_uu_id": company_uu_id}
)
def create_staff_via_list(list_of_staff):
for staff in list_of_staff:
duty_response = requester.post(
endpoint="duty/list",
data={"query": dict(duty_name=staff["duty"])},
)
selected_duty = duty_response.json()["data"][0]["uu_id"]
duties_response = requester.post(
endpoint="duties/get_by_duty_uuid",
data={"duty_uu_id": selected_duty},
)
selected_duties = duties_response.json()["data"][0]["uu_id"]
staff_dict = staff
del staff_dict["duty"]
staff_dict["duties_uu_id"] = selected_duties
request_staff = requester.post(
data={**staff_dict, **active_and_confirmed}, endpoint="staff/create"
)
print(request_staff.json())
def create_employee_via_list(list_of_staff):
for staff in list_of_staff:
duty_response = requester.post(
endpoint="duty/list",
data={"query": dict(duty_name=staff["duty_name"])},
)
selected_duty = duty_response.json()["data"][0]["uu_id"]
duties_response = requester.post(
endpoint="duties/get_by_duty_uuid",
data={"duty_uu_id": selected_duty},
)
selected_duties = duties_response.json()["data"][0]["uu_id"]
request_staff = requester.post(
data={"duties_uu_id": selected_duties}, endpoint="staff/get_by_duties_uu_id"
)
selected_staffs_obj = request_staff.json()["data"][0]
selected_staffs_uu_id = selected_staffs_obj["uu_id"]
if "Temsilcisi" in selected_staffs_obj["staff_name"]:
for i in range(0, 5):
request_create_staff = requester.post(
endpoint="employee/create",
data={
"staff_uu_id": selected_staffs_uu_id,
"people_uu_id": None,
**active_and_confirmed,
},
)
print(request_create_staff.json())
elif "Elemanı" in selected_staffs_obj["staff_name"]:
for i in range(0, 2):
request_create_staff = requester.post(
endpoint="employee/create",
data={
"staff_uu_id": selected_staffs_uu_id,
"people_uu_id": None,
**active_and_confirmed,
},
)
print(request_create_staff.json())
else:
request_create_staff = requester.post(
endpoint="employee/create",
data={
"staff_uu_id": selected_staffs_uu_id,
"people_uu_id": None,
**active_and_confirmed,
},
)
print(request_create_staff.json())
print(request_staff.json())
def create_people_via_list(people_count: int):
for people in range(people_count):
people = create_random_person()
people_dict = people.model_dump()
request_people = requester.post(
data={**people_dict, **active_and_confirmed}, endpoint="people/create"
)
response_person = request_people.json()
selected_person_uu_id = response_person["data"]["uu_id"]
insert_user = create_random_user(selected_person_uu_id)
request_user = requester.post(
data={**active_and_confirmed, **insert_user}, endpoint="user/create"
)
response_user = request_user.json()
selected_user_uu_id = response_user["data"]["uu_id"]
def create_occupant_people_via_list(people_count: int):
for people in range(people_count):
people = create_random_person()
people_dict = people.model_dump()
request_people = requester.post(
data={**people_dict, **active_and_confirmed}, endpoint="people/create"
)
response_person = request_people.json()
selected_person_uu_id = response_person["data"]["uu_id"]
insert_user = create_random_occupant_user(selected_person_uu_id)
request_user = requester.post(
data={**active_and_confirmed, **insert_user}, endpoint="user/create"
)
response_user = request_user.json()
selected_user_uu_id = response_user["data"]["uu_id"]
def run_company_and_depends(company_uu_id):
create_department_via_list(list_of_departments=departments)
create_duty_via_list(list_of_duties=duties)
create_duties_via_list(list_of_duties=duties, company_uu_id=company_uu_id)
create_staff_via_list(list_of_staff=staffs)
create_employee_via_list(list_of_staff=duties)
create_people_via_list(people_count=10)
create_occupant_people_via_list(people_count=70)
print("Program ended **-------------------------------------")

View File

@@ -0,0 +1,375 @@
departments = [
{
"department_name": "İcra Kurulu Departmanı",
"department_code": "İCK",
"department_description": "İcra Kurulu Departmanı",
},
{
"department_name": "Mali İşler Departmanı",
"department_code": "MD",
"department_description": "Mali İşler Departmanı",
},
{
"department_name": "İnsan Kaynakları Departmanı",
"department_code": "IKD",
"department_description": "İnsan Kaynakları Departmanı",
},
{
"department_name": "Satış Departmanı",
"department_code": "SD",
"department_description": "Satış Departmanı",
},
{
"department_name": "Bilgi Teknolojileri Departmanı",
"department_code": "BTD",
"department_description": "Bilgi Teknolojileri Departmanı",
},
]
duties = [
{
"department_name": "İcra Kurulu Departmanı",
"duty_name": "Genel Müdür",
"duty_code": "GM",
"duty_description": "Genel Müdür",
},
{
"department_name": "İcra Kurulu Departmanı",
"duty_name": "Mali İşler Direktörlüğü",
"duty_code": "MD",
"duty_description": "Mali İşler Direktörlüğü",
},
{
"department_name": "İcra Kurulu Departmanı",
"duty_name": "İnsan Kaynakları Direktörlüğü",
"duty_code": "İKD",
"duty_description": "İnsan Kaynakları Direktörlüğü",
},
{
"department_name": "İcra Kurulu Departmanı",
"duty_name": "Satış Direktörlüğü",
"duty_code": "SD",
"duty_description": "Satış Direktörlüğü",
},
{
"department_name": "İcra Kurulu Departmanı",
"duty_name": "Bilgi Teknolojileri Direktörlüğü",
"duty_code": "BTD",
"duty_description": "Bilgi Teknolojileri Direktörlüğü",
},
{
"department_name": "Mali İşler Departmanı",
"duty_name": "Muhasebe Müdürlüğü",
"duty_code": "MM",
"duty_description": "Muhasebe Müdürlüğü",
},
{
"department_name": "Mali İşler Departmanı",
"duty_name": "Finans Müdürlüğü",
"duty_code": "FM",
"duty_description": "Finans Müdürlüğü",
},
{
"department_name": "Mali İşler Departmanı",
"duty_name": "Muhasabe Şefliği",
"duty_code": "MS",
"duty_description": "Muhasabe Şefliği",
},
{
"department_name": "Mali İşler Departmanı",
"duty_name": "Muhasebe Uzmanı",
"duty_code": "MU",
"duty_description": "Muhasebe Uzmanı",
},
{
"department_name": "Mali İşler Departmanı",
"duty_name": "Muhasebe Elemanı",
"duty_code": "ME",
"duty_description": "Muhasebe Elemanı",
},
{
"department_name": "Mali İşler Departmanı",
"duty_name": "Finans Şefliği",
"duty_code": "FS",
"duty_description": "Finans Şefliği",
},
{
"department_name": "Mali İşler Departmanı",
"duty_name": "Finans Uzmanı",
"duty_code": "FU",
"duty_description": "Finans Uzmanı",
},
{
"department_name": "Mali İşler Departmanı",
"duty_name": "Finans Elemanı",
"duty_code": "FE",
"duty_description": "Finans Elemanı",
},
{
"department_name": "İnsan Kaynakları Departmanı",
"duty_name": "İnsan Kaynakları Müdürlüğü",
"duty_code": "İKM",
"duty_description": "İnsan Kaynakları Müdürlüğü",
},
{
"department_name": "İnsan Kaynakları Departmanı",
"duty_name": "İnsan Kaynakları Şefliği",
"duty_code": "İKS",
"duty_description": "İnsan Kaynakları Şefliği",
},
{
"department_name": "İnsan Kaynakları Departmanı",
"duty_name": "İnsan Kaynakları Uzmanı",
"duty_code": "İKU",
"duty_description": "İnsan Kaynakları Uzmanı",
},
{
"department_name": "İnsan Kaynakları Departmanı",
"duty_name": "İnsan Kaynakları Elemanı",
"duty_code": "İKE",
"duty_description": "İnsan Kaynakları Elemanı",
},
{
"department_name": "Satış Departmanı",
"duty_name": "Satış Müdürlüğü",
"duty_code": "SM",
"duty_description": "Satış Müdürlüğü",
},
{
"department_name": "Satış Departmanı",
"duty_name": "Satış Bölge Şefliği",
"duty_code": "SS",
"duty_description": "Satış Bölge Şefliği",
},
{
"department_name": "Satış Departmanı",
"duty_name": "Satış Temsilcisi",
"duty_code": "ST",
"duty_description": "Satış Temsilcisi",
},
{
"department_name": "Bilgi Teknolojileri Departmanı",
"duty_name": "Veri Tabanı Yöneticisi",
"duty_code": "VTY",
"duty_description": "Veri Tabanı Yöneticisi",
},
{
"department_name": "Bilgi Teknolojileri Departmanı",
"duty_name": "Aplikasyon Sorumlusu",
"duty_code": "AS",
"duty_description": "Aplikasyon Sorumlusu",
},
{
"department_name": "Bilgi Teknolojileri Departmanı",
"duty_name": "Ağ Yöneticisi",
"duty_code": "AY",
"duty_description": "Ağ Yöneticisi",
},
]
staffs = [
{
"staff_name": "Genel Müdür",
"staff_code": "GM",
"staff_description": "Genel Müdür",
"duty": "Genel Müdür",
},
{
"staff_name": "Mali İşler Direktörü",
"staff_code": "MD",
"staff_description": "Mali İşler Direktörü",
"duty": "Mali İşler Direktörlüğü",
},
{
"staff_name": "İnsan Kaynakları Direktörü",
"staff_code": "İKD",
"staff_description": "İnsan Kaynakları Direktörü",
"duty": "İnsan Kaynakları Direktörlüğü",
},
{
"staff_name": "Satış Direktörü",
"staff_code": "SD",
"staff_description": "Satış Direktörü",
"duty": "Satış Direktörlüğü",
},
{
"staff_name": "Bilgi Teknolojileri Direktörü",
"staff_code": "BTD",
"staff_description": "Bilgi Teknolojileri Direktörü",
"duty": "Bilgi Teknolojileri Direktörlüğü",
},
{
"staff_name": "Muhasebe Müdürü",
"staff_code": "MM",
"staff_description": "Muhasebe Müdürü",
"duty": "Muhasebe Müdürlüğü",
},
{
"staff_name": "Finans Müdürü",
"staff_code": "FM",
"staff_description": "Finans Müdürü",
"duty": "Finans Müdürlüğü",
},
{
"staff_name": "Muhasabe Şefi",
"staff_code": "MS",
"staff_description": "Muhasabe Şefi",
"duty": "Muhasabe Şefliği",
},
{
"staff_name": "Muhasebe Uzmanı",
"staff_code": "MU",
"staff_description": "Muhasebe Uzmanı",
"duty": "Muhasebe Uzmanı",
},
{
"staff_name": "Digital Muhasabe Elemanı",
"staff_code": "ME",
"staff_description": "Digital Muhasabe Elemanı",
"duty": "Muhasebe Elemanı",
},
{
"staff_name": "Muhasabe Elemanı",
"staff_code": "ME",
"staff_description": "Muhasabe Elemanı",
"duty": "Muhasebe Elemanı",
},
{
"staff_name": "Finans Şefi",
"staff_code": "FS",
"staff_description": "Finans Şefi",
"duty": "Finans Şefliği",
},
{
"staff_name": "Finans Uzmanı",
"staff_code": "FU",
"staff_description": "Finans Uzmanı",
"duty": "Finans Uzmanı",
},
{
"staff_name": "Finans Elemanı",
"staff_code": "FE",
"staff_description": "Finans Elemanı",
"duty": "Finans Elemanı",
},
{
"staff_name": "İnsan Kaynakları Müdürü",
"staff_code": "İKM",
"staff_description": "İnsan Kaynakları Müdürü",
"duty": "İnsan Kaynakları Müdürlüğü",
},
{
"staff_name": "İnsan Kaynakları Şefi",
"staff_code": "İKS",
"staff_description": "İnsan Kaynakları Şefi",
"duty": "İnsan Kaynakları Şefliği",
},
{
"staff_name": "İnsan Kaynakları Uzmanı",
"staff_code": "İKU",
"staff_description": "İnsan Kaynakları Uzmanı",
"duty": "İnsan Kaynakları Uzmanı",
},
{
"staff_name": "İnsan Kaynakları Elemanı",
"staff_code": "İKE",
"staff_description": "İnsan Kaynakları Elemanı",
"duty": "İnsan Kaynakları Elemanı",
},
{
"staff_name": "Satış Müdürü",
"staff_code": "SM",
"staff_description": "Satış Müdürü",
"duty": "Satış Müdürlüğü",
},
{
"staff_name": "Satış Ankara Bölge Şefi",
"staff_code": "SS",
"staff_description": "Satış Ankara Bölge Şefi",
"duty": "Satış Bölge Şefliği",
},
{
"staff_name": "Satış İstanbul Bölge Şefi",
"staff_code": "SS",
"staff_description": "Satış İstanbul Bölge Şefi",
"duty": "Satış Bölge Şefliği",
},
{
"staff_name": "Satış İzmir Bölge Şefi",
"staff_code": "SS",
"staff_description": "Satış İzmir Bölge Şefi",
"duty": "Satış Bölge Şefliği",
},
{
"staff_name": "Satış Ankara Çankaya Temsilcisi",
"staff_code": "ST",
"staff_description": "Satış Ankara Çankaya Temsilcisi",
"duty": "Satış Temsilcisi",
},
{
"staff_name": "Satış Ankara Keçiören Temsilcisi",
"staff_code": "ST",
"staff_description": "Satış Ankara Keçiören Temsilcisi",
"duty": "Satış Temsilcisi",
},
{
"staff_name": "Satış Ankara Yenimahalle Temsilcisi",
"staff_code": "ST",
"staff_description": "Satış Ankara Yenimahalle Temsilcisi",
"duty": "Satış Temsilcisi",
},
{
"staff_name": "Satış İstanbul Beylikdüzü Temsilcisi",
"staff_code": "ST",
"staff_description": "Satış İstanbul Beylikdüzü Temsilcisi",
"duty": "Satış Temsilcisi",
},
{
"staff_name": "Satış İstanbul Kadıköy Temsilcisi",
"staff_code": "ST",
"staff_description": "Satış İstanbul Kadıköy Temsilcisi",
"duty": "Satış Temsilcisi",
},
{
"staff_name": "Satış İstanbul Üsküdar Temsilcisi",
"staff_code": "ST",
"staff_description": "Satış İstanbul Üsküdar Temsilcisi",
"duty": "Satış Temsilcisi",
},
{
"staff_name": "Satış İzmir Bornova Temsilcisi",
"staff_code": "ST",
"staff_description": "Satış İzmir Bornova Temsilcisi",
"duty": "Satış Temsilcisi",
},
{
"staff_name": "Veri Tabanı Yöneticisi",
"staff_code": "VTY",
"staff_description": "Veri Tabanı Yöneticisi",
"duty": "Veri Tabanı Yöneticisi",
},
{
"staff_name": "Aplikasyon Sorumlusu",
"staff_code": "AS",
"staff_description": "Aplikasyon Sorumlusu",
"duty": "Aplikasyon Sorumlusu",
},
{
"staff_name": "Super User",
"staff_code": "AS",
"staff_description": "Super User",
"duty": "Aplikasyon Sorumlusu",
},
{
"staff_name": "Ağ Yöneticisi",
"staff_code": "AY",
"staff_description": "Ağ Yöneticisi",
"duty": "Ağ Yöneticisi",
},
]
list_options = {
"page": 1,
"size": 10,
"order_field": "id",
"order_type": "asc",
"include_joins": [],
"query": {},
}

View File

@@ -0,0 +1,23 @@
from test_application.evyos.bases import requester
from test_application.evyos.datas.company_employee_data import list_options
def list_building_types(lang: str = "TR", type_code: str = None):
options_smart_query = {
**list_options,
"query": {
"lang": lang,
},
}
if type_code:
options_smart_query["query"]["type_code__ilike"] = type_code
response = requester.post(
endpoint="/building/types/list",
data=options_smart_query,
)
print("text", response.text)
print("json", response.json())
return response.json()
# list_building_types(type_code="apt")

View File

@@ -0,0 +1,21 @@
from test_application.evyos.bases import requester
def get_occupants_types(occupant_code):
response = requester.post(
endpoint="/occupant_types/get/code",
data={"type_code": occupant_code},
)
print("text", response.text)
print("json", response.json())
return response.json()
def get_occupants_types_uu_id(occupant_uu_id):
response = requester.post(
endpoint="/occupant_types/get/uu_id",
data={"uu_id": occupant_uu_id},
)
print("text", response.text)
print("json", response.json())
return response.json()

View File

@@ -0,0 +1,45 @@
from test_application.evyos.bases import requester
def get_type_codes_key_and_class(class_name, key_name):
response = requester.post(
endpoint="/enums/get/key",
data={"class_name": class_name, "key_name": key_name},
)
print("text", response.text)
print("json", response.json())
return response.json()
def get_type_codes_via_uuid(uu_id):
response = requester.post(
endpoint="/enums/get/uu_id",
data={"uu_id": uu_id},
)
print("text", response.text)
print("json", response.json())
return response.json()
def get_all_type_codes():
response = requester.post(
endpoint="/enums/list/all",
data={},
)
print("text", response.text)
print("json", response.json())
return response.json()
def get_all_type_codes_with_class(class_name):
response = requester.post(
endpoint="/enums/list/class",
data={"class_name": class_name},
)
print("text", response.text)
print("json", response.json())
return response.json()
# get_type_codes(class_name="buildmanagementtype", key_name="BM")
# get_all_type_codes()

View File

@@ -0,0 +1,109 @@
import arrow
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_type_codes import get_type_codes_key_and_class
from test_application.evyos.address_building import list_building
decision_book_dict = lambda build_uu_id, resp_company_uu_id: {
"build_uu_id": build_uu_id,
"decision_type": "RBM",
"meeting_date": str(arrow.now().date()),
"is_out_sourced": True,
"resp_company_uu_id": resp_company_uu_id,
**active_and_confirmed,
}
event_bind_to_occupant = lambda event_uu_id_list, build_living_space_uu_id: {
"event_uu_id_list": list(event_uu_id_list),
"build_living_space_uu_id": str(build_living_space_uu_id),
}
def get_uu_id_of_enum(enum_class: str, key: str):
get_type_codes_response = get_type_codes_key_and_class(
class_name=enum_class, key_name=key
)
return get_type_codes_response["data"]["uu_id"]
def list_company():
response = requester.post(
endpoint="/company/list",
data=list_options,
)
print("text", response.text)
print("json", response.json())
return response.json()
def list_decision_books():
response = requester.post(
endpoint="/build/decision_book/list",
data=list_options,
)
print("text", response.text)
print("json", response.json())
return response.json()
def list_decision_book_items():
response = requester.post(
endpoint="/build/decision_book/items/list",
data=list_options,
)
print("text", response.text)
print("json", response.json())
return response.json()
def create_decision_book(decision_book):
response = requester.post(
endpoint="/build/decision_book/create",
data=decision_book,
)
print("text", response.text)
print("json", response.json())
return response.json()
def give_service_access_to_occupant(occupant_dict):
response = requester.post(
endpoint="/bind/services/occupant",
data=occupant_dict,
)
print("text", response.text)
print("json", response.json())
return response.json()
def give_event_access_to_build_decision_book_items(occupant_dict):
response = requester.post(
endpoint="/bind/events/occupant",
data={
"occupant_uu_id": occupant_dict["occupant_uu_id"],
"build_part_uu_id": occupant_dict["build_part_uu_id"],
"event_uu_id_list": list(occupant_dict["event_uu_id_list"]),
"is_confirmed": True,
},
)
print("text", response.text)
print("json", response.json())
return response.json()
def run_decision_book_depends():
build_response = list_building()
selected_build_uu_id = build_response["data"][0]["uu_id"]
company_response = list_company()
selected_company_uu_id = company_response["data"][0]["uu_id"]
create_decision_book(
decision_book_dict(
build_uu_id=selected_build_uu_id,
resp_company_uu_id=selected_company_uu_id,
)
)
decision_book = list_decision_books()["data"][0]["uu_id"]
return decision_book

View 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,
)

View File

@@ -0,0 +1,68 @@
from test_application.evyos.bases import requester, active_and_confirmed
employee_endpoint = "/employee/employ"
fire_endpoint = "/employee/fire"
staff_endpoint = "/staff/list"
people_endpoint = "/people/list"
def bind_people_to_employee(identity_no: str, staff_uu_id: str, expiry_starts: str):
people_response = requester.post(
data={"query": {"national_identity_id": identity_no}}, endpoint=people_endpoint
)
print("people_response tx", people_response.text)
print("people_response", people_response.json())
people_uu_id = people_response.json()["data"][0]["uu_id"]
print("People UUID", people_uu_id)
staff_response = requester.post(
data={"query": {"uu_id": staff_uu_id}}, endpoint=staff_endpoint
)
print("staff_response tx", staff_response.text)
print("staff_response", staff_response.json())
staff_uu_id = staff_response.json()["data"][0]["uu_id"]
print("Staff UUID", staff_uu_id)
data_dict = {
"people_uu_id": people_uu_id,
"staff_uu_id": staff_uu_id,
"expiry_starts": expiry_starts,
**active_and_confirmed,
}
bind_employee_people_response = requester.post(
data=data_dict, endpoint=employee_endpoint
)
print("bind_employee_people_response", bind_employee_people_response.text)
print("bind_employee_people_response", bind_employee_people_response.json())
def fire_people_from_employee(identity_no: str, expiry_ends: str):
people_response = requester.post(
data={"query": {"national_identity_id": identity_no}}, endpoint=people_endpoint
)
print("people_response tx", people_response.text)
print("people_response", people_response.json())
people_uu_id = people_response.json()["data"][0]["uu_id"]
print("People UUID", people_uu_id)
data_dict = {
"people_uu_id": people_uu_id,
"expiry_ends": expiry_ends,
**active_and_confirmed,
}
fire_employee_people_response = requester.post(
data=data_dict, endpoint=fire_endpoint
)
print("fire_employee_people_response", fire_employee_people_response.text)
print("fire_employee_people_response", fire_employee_people_response.json())
bind_people_to_employee(
identity_no="46546125608",
staff_uu_id="96f6a822-ae37-4644-a56a-811d47209c9d",
expiry_starts="2024-10-01",
)
# fire_people_from_employee(
# identity_no="91222781086"
# )

View File

@@ -0,0 +1,123 @@
import random
from datetime import datetime, timedelta
from validations import InsertPerson, InsertUsers
from faker import Faker
faker_engine = Faker(["tr-TR"])
def generate_random_country_code():
return random.choice(["TR", "EN"])
def generate_random_digit(n):
return random.randint(10 ** (n - 1), 10**n)
def generate_random_gender():
return random.choice(["M", "F"])
def generate_random_city_code():
return random.choice(["ANK", "IST", "IZM"])
def generate_random_phone_number():
return f"+90{''.join([str(random.randint(0, 9)) for _ in range(10)])}"
def generate_random_coordinates():
latitude = random.uniform(-90, 90)
longitude = random.uniform(-180, 180)
return latitude, longitude
def generate_random_profile():
"""
asd = {
'job': 'Belediye meclisi üyesi', 'company': 'Zorlu Enerji', 'ssn': '33384169120',
'residence': 'Unit 2753 Box 0533\nDPO AE 94969', 'current_location': (Decimal('57.4049185'), Decimal('56.715540')),
'blood_group': 'B+', 'website': ['https://borusan.tr/'], 'username': 'mugberdemirel', 'name': 'Kelâmi Yorulmaz',
'sex': 'M', 'address': '39314 Zorlu Ramp\nEast Ömürberg, MO 85532', 'mail': 'denizalp28@yandex.com',
'birthdate': datetime.date(2017, 8, 20)
}
"""
return faker_engine.profile()
def create_random_email(people_id: int = None, company_id: int = None):
return {
"email": faker_engine.email(domain="evyos.com.tr"),
"expiry_starts": datetime.now().__str__(),
"expiry_ends": str(datetime.now() + timedelta(days=365)),
"email_name": faker_engine.email(domain="evyos.com.tr").split("@")[0],
"people_id": people_id,
"company_id": company_id,
}
def create_random_phone(people_id: int = None, company_id: int = None):
return {
"country_code": generate_random_country_code(),
"phone_no": generate_random_phone_number(),
"city_code": generate_random_city_code(),
"expiry_starts": datetime.now().__str__(),
"expiry_ends": str(datetime.now() + timedelta(days=365)),
"description": faker_engine.text(max_nb_chars=50),
"people_id": people_id,
"company_id": company_id,
}
def create_random_person():
profile = generate_random_profile()
return InsertPerson(
**{
"firstname": faker_engine.first_name(),
"surname": faker_engine.last_name(),
"middle_name": faker_engine.name_male().split(" ")[1],
"father_name": faker_engine.name_male().replace(".", ""),
"mother_name": faker_engine.name_female().replace(".", ""),
"sex_code": profile.get("sex"),
"country_code": generate_random_country_code(),
"national_identity_id": str(generate_random_digit(n=11)),
"birth_place": faker_engine.city(),
"birth_date": faker_engine.date_of_birth(
minimum_age=25, maximum_age=50
).__str__(),
"tax_no": str(generate_random_digit(n=10)),
"is_employee_related": True,
"is_living_space_related": False,
}
)
def create_random_user(people_id: int):
profile = generate_random_profile()
insert_user = InsertUsers(
**dict(
user_tag=profile.get("username"),
domain_name="wag.evyos.com",
email=faker_engine.email(domain="evyos.com.tr"),
phone_number=generate_random_phone_number(),
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
people_uu_id=str(people_id),
)
)
return insert_user.excluded_dump()
def create_random_occupant_user(people_id: int):
profile = generate_random_profile()
insert_user = InsertUsers(
**dict(
user_tag=profile.get("username"),
domain_name="wag.evyos.com",
email=faker_engine.email(),
phone_number=generate_random_phone_number(),
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
people_uu_id=str(people_id),
)
)
return insert_user.excluded_dump()

View File

@@ -0,0 +1,153 @@
import arrow
from test_application.evyos.bases import login_via_email_and_password
from test_application.evyos.company_employee import run_company_and_depends
from test_application.evyos.address_building import run_address_to_building
from test_application.evyos.datas.get_type_codes import get_type_codes_key_and_class
from test_application.evyos.decision_book import (
run_decision_book_depends,
list_decision_books,
)
from test_application.evyos.decision_book_items import (
run_decision_book_items,
send_invitation_to_building_residents,
collect_invitation_to_building_residents,
assign_people_to_pre_or_wrt,
)
login_creds_employee = {
"domain": "evyos.com.tr",
"access_key": "karatay.berkay.sup@evyos.com.tr",
"password": "string",
"remember_me": False,
"password_token": ""
}
access_key_president = "bmanco@example.net"
login_creds_occupant = {
"domain": "evyos.com.tr",
"access_key": access_key_president,
"password": "string",
"remember_me": False,
"password_token": "o_2Y_yXS-cl6MxLbzLrXQetXTlDLD3UBDTQNa_mBMyzSOVIgx3LGbnufLRJjd4g6BWFbwVgJIUxbK-Pi0R5dwxfVJKyoEeDdej40uRHSsElKR16nvnqgFB_BJ4nmyN0KSunZHra5NqHJor17EGExOSmlttZV5dC7vFsrc-GUkg"
}
wrt_creds_occupant = {
"domain": "evyos.com.tr",
"access_key": access_key_president,
"password": "string",
"remember_me": False,
"password_token": "",
}
add_with_employee = None
add_with_occupant = True
assign_people_to_create_item = 3
# selection_list = None
selection_list = ["7e370616-7bcf-469f-b9a2-c0da55463939", "c2d385d8-b772-4ecd-be89-8c468738654a"]
# selection_list = None
manager_token = ""
writers_token = manager_token
people_uu_id_list = []
list_of_attendees = []
if add_with_employee:
select_occupant = login_via_email_and_password(
login_data=login_creds_employee, is_password_valid=False
)
print("select_company_uu_id", select_occupant)
run_company_and_depends(company_uu_id=select_occupant)
run_address_to_building()
if add_with_occupant:
select_occupant = login_via_email_and_password(
login_data=login_creds_occupant,
is_password_valid=False,
selection_list=selection_list,
)
if assign_people_to_create_item == 0:
selected_decision_book_uu_id = run_decision_book_depends()
send_invitation = {
"build_decision_book_uu_id": selected_decision_book_uu_id,
"message": "Request for a Regular Building Meeting",
"planned_date": arrow.now().shift(days=2).date().__str__(),
}
send_invitation_to_building_residents(send_invitation_dict=send_invitation)
if assign_people_to_create_item == 1:
count = 17
list_of_attendees.insert(0, manager_token)
collect_invitation_to_building_residents(
attended_dict_list=list_of_attendees, attend_count=count + 1
)
elif assign_people_to_create_item == 2:
assign_people_to_pre_or_wrt(
person_uu_id=people_uu_id_list[0],
manager_token=manager_token,
occupant_code="MT-VPR",
)
assign_people_to_pre_or_wrt(
person_uu_id=people_uu_id_list[1],
manager_token=manager_token,
occupant_code="MT-WRT",
)
assign_people_to_pre_or_wrt(
person_uu_id=people_uu_id_list[2],
manager_token=manager_token,
occupant_code="MT-PRS",
)
elif assign_people_to_create_item == 3:
select_occupant = login_via_email_and_password(
login_data=wrt_creds_occupant,
is_password_valid=True,
selection_list=selection_list,
)
selected_decision_book_uu_id = list_decision_books()["data"][0]["uu_id"]
print("select_company_uu_id", select_occupant)
is_fixed_price = False
info_type_d_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-D"
)["data"]["uu_id"]
unit_price = 15.90
run_decision_book_items(
writers_token=writers_token, unit_price=unit_price, is_fixed=is_fixed_price,
info_type_uu_id=info_type_d_uu_id
)
is_fixed_price = True
info_type_a_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-A"
)["data"]["uu_id"]
start_date, end_date = "2024-11-01", "2025-02-01"
unit_price = 850
run_decision_book_items(
writers_token=writers_token, unit_price=unit_price, is_fixed=is_fixed_price,
info_type_uu_id=info_type_a_uu_id, start_date=start_date, end_date=end_date
)
info_type_a_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-R"
)["data"]["uu_id"]
unit_price = 5000
run_decision_book_items(
writers_token=writers_token, unit_price=unit_price, is_fixed=is_fixed_price,
info_type_uu_id=info_type_a_uu_id, start_date=start_date, end_date=end_date
)
info_type_a_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-R"
)["data"]["uu_id"]
unit_price = 2000
run_decision_book_items(
writers_token=writers_token, unit_price=unit_price, is_fixed=is_fixed_price,
info_type_uu_id=info_type_a_uu_id, start_date=start_date, end_date=end_date
)
info_type_a_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-L"
)["data"]["uu_id"]
unit_price = 750
run_decision_book_items(
writers_token=writers_token, unit_price=unit_price, is_fixed=is_fixed_price,
info_type_uu_id=info_type_a_uu_id, start_date=start_date, end_date=end_date
)

View File

@@ -0,0 +1,22 @@
# occupant_dict = {
# "occupant_uu_id": "79def7b2-017e-46a4-8ed0-27e67130ebec",
# "build_part_uu_id": "1a661e95-ad23-4898-b751-44cde024bcbe",
# "event_uu_id_list": [""]
# }
def generate_query_with_function_codes(function_codes):
print(
"""
SELECT x.uu_id FROM public.events x
where x.function_code in("""
)
codes = ""
for function_code in function_codes:
codes += f"'{function_code}',\n"
print(codes[:-2])
print(
""")
ORDER BY x.uu_id
"""
)