Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
fix: Add more tests, add unimplemented debug to stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
rsavoye committed Dec 23, 2023
1 parent c26d38a commit 10e048c
Show file tree
Hide file tree
Showing 5 changed files with 287 additions and 119 deletions.
53 changes: 53 additions & 0 deletions tests/test_dbsupport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/python3

# Copyright (c) 2022, 2023 Humanitarian OpenStreetMap Team
#
# This file is part of tm-admin.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with tm-admin. If not, see <https:#www.gnu.org/licenses/>.
#

import logging
import os
import argparse
import sys

# import tm_admin as tma
# rootdir = tma.__path__[0]

# Instantiate logger
log = logging.getLogger(__name__)

# def test_dummy():
# """Placeholder to allow CI to pass."""
# assert True

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", nargs="?", const="0", help="verbose output")
args = parser.parse_args()

# if verbose, dump to the terminal.
log_level = os.getenv("LOG_LEVEL", default="INFO")
if args.verbose is not None:
log_level = logging.DEBUG
logging.basicConfig(
level=log_level,
format=("%(asctime)s.%(msecs)03d [%(levelname)s] " "%(name)s | %(funcName)s:%(lineno)d | %(message)s"),
datefmt="%y-%m-%d %H:%M:%S",
stream=sys.stdout,
)

# test_dummy()
log.debug("foo")
142 changes: 119 additions & 23 deletions tests/test_orgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,105 @@

organization = OrganizationsDB('localhost/tm_admin')

def test_all():
all = organization.getAll()
assert len(all) > 0

def test_by_id():
id = 100
all = organization.getByID(id)
assert len(all) > 0

def test_by_name():
name = 'Peace Corps'
all = organization.getByName(name)
assert len(all) > 0
def get_organisation_by_id():
log.debug(f"get_organisation_by_id()")
# organisation_id: int) -> Organisation:
pass

def get_organisation_by_name():
# organisation_name: str) -> Organisation:
log.debug(f"get_organisation_by_name() unimplemented!")
pass

def get_organisation_name_by_id():
# organisation_id: int) -> str:
log.debug(f"get_organisation_name_by_id() unimplemented!")
pass

def create_organisation():
# new_organisation_dto: NewOrganisationDTO) -> int:
log.debug(f"create_organisation() unimplemented!")
pass

def update_organisation():
# organisation_dto: UpdateOrganisationDTO) -> Organisation:
log.debug(f"update_organisation() unimplemented!")
pass

def delete_organisation():
# organisation_id: int):
log.debug(f"delete_organisation() unimplemented!")
pass

def get_organisations():
# manager_user_id: int):
log.debug(f"get_organisations() unimplemented!")
pass

def get_organisations_managed_by_user():
# user_id: int):
log.debug(f"get_organisations_managed_by_user() unimplemented!")
pass

def get_organisations_managed_by_user_as_dto():
# user_id: int) -> ListOrganisationsDTO:
log.debug(f"get_organisations_managed_by_user_as_dto() unimplemented!")
pass

def get_projects_by_organisation_id():
# organisation_id: int) -> Organisation:
log.debug(f"get_projects_by_organisation_id() unimplemented!")
pass

def get_organisation_stats():
#
log.debug(f"get_organisation_stats() unimplemented!")
pass

def assert_validate_name():
# org: Organisation, name: str):
log.debug(f"assert_validate_name() unimplemented!")
pass

def assert_validate_users():
# organisation_dto: OrganisationDTO):
log.debug(f"assert_validate_users() unimplemented!")
pass

def can_user_manage_organisation():
# organisation_id: int, user_id: int):
log.debug(f"can_user_manage_organisation() unimplemented!")
pass

def is_user_an_org_manager():
# organisation_id: int, user_id: int):
log.debug(f"is_user_an_org_manager() unimplemented!")
pass

def get_campaign_organisations_as_dto():
# campaign_id: int, user_id: int):
log.debug(f"get_campaign_organisations_as_dto() unimplemented!")
pass

def get_organisation_by_id_as_dto():
#
log.debug(f"get_organisation_by_id_as_dto() unimplemented!")
pass

def get_organisation_by_slug_as_dto():
# slug: str, user_id: int, abbreviated: bool):
log.debug(f"get_organisation_by_slug_as_dto() unimplemented!")
pass

def get_organisation_dto():
# org, user_id: int, abbreviated: bool):
log.debug(f"get_organisation_dto() unimplemented!")
pass

def get_organisations_as_dto():
#
log.debug(f"get_organisations_as_dto() unimplemented!")
pass

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand All @@ -72,13 +158,23 @@ def test_by_name():
stream=sys.stdout,
)

print("--- test_by_id() ---")
test_by_id()

print("--- test_by_name() ---")
test_by_name()

print("--- test_all() ---")
test_all()


get_organisation_by_id()
get_organisation_by_name()
get_organisation_name_by_id()
create_organisation()
update_organisation()
delete_organisation()
get_organisations()
get_organisations_managed_by_user()
get_projects_by_organisation_id()
get_organisation_stats()
assert_validate_name()
assert_validate_users()
can_user_manage_organisation()
is_user_an_org_manager()
# get_campaign_organisations_as_dto()
# get_organisations_managed_by_user_as_dto()
# get_organisation_by_id_as_dto()
# get_organisation_by_slug_as_dto()
# get_organisation_dto()
# get_organisations_as_dto(
Empty file modified tests/test_placeholder.py
100644 → 100755
Empty file.
63 changes: 32 additions & 31 deletions tests/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,121 +48,122 @@

def get_project_by_id():
# project_id: int) -> Project:
pass
log.debug(f"get_project_by_id() unimplemented!")

def exists():
# project_id: int) -> bool:
pass
log.debug(f"exists() unimplemented!")

def get_project_by_name():
# project_id: int) -> Project:
pass
log.debug(f"get_project_by_name() unimplemented!")

def auto_unlock_tasks():
# project_id: int):
pass
log.debug(f"auto_unlock_tasks() unimplemented!")

def delete_tasks():
# project_id: int, tasks_ids):
pass
log.debug(f"delete_tasks() unimplemented!")

def get_contribs_by_day():
# project_id: int) -> ProjectContribsDTO:
pass
log.debug(f"get_contribs_by_day() unimplemented!")

def get_project_dto_for_mapper():
pass
log.debug(f"get_project_dto_for_mapper() unimplemented!")

def get_project_tasks():
pass
#
log.debug(f"get_project_tasks() unimplemented!")

def get_project_aoi():
# project_id):
pass
log.debug(f"get_project_aoi() unimplemented!")

def get_project_priority_areas():
# project_id):
pass
log.debug(f"get_project_priority_areas() unimplemented!")

def get_task_for_logged_in_user():
# user_id: int):
pass
log.debug(f"get_task_for_logged_in_user() unimplemented!")

def get_task_details_for_logged_in_user():
# user_id: int, preferred_locale: str):
pass
log.debug(f"get_task_details_for_logged_in_user() unimplemented!")

def is_user_in_the_allowed_list():
# allowed_users: list, current_user_id: int):
pass
log.debug(f"is_user_in_the_allowed_list() unimplemented!")

def evaluate_mapping_permission():
pass
log.debug(f"evaluate_mapping_permission() unimplemented!")

def evaluate_validation_permission():
pass
log.debug(f"evaluate_validation_permission() unimplemented!")

def is_user_permitted_to_validate():
# project_id, user_id):
pass
log.debug(f") unimplemented!")

def is_user_permitted_to_map():
# project_id, user_id):
pass
log.debug(f"is_user_permitted_to_map() unimplemented!")

def get_cached_project_summary():
pass
log.debug(f"get_cached_project_summary() unimplemented!")

def get_project_summary():
pass
log.debug(f") unimplemented!")

def set_project_as_featured():
# project_id: int):
pass
log.debug(f"set_project_as_featured() unimplemented!")

def unset_project_as_featured():
# project_id: int):
pass
log.debug(f"unset_project_as_featured() unimplemented!")

def get_featured_projects():
# preferred_locale):
pass
log.debug(f"get_featured_projects() unimplemented!")

def is_favorited():
# project_id: int, user_id: int) -> bool:
pass
log.debug(f"is_favorited() unimplemented!")

def favorite():
# project_id: int, user_id: int):
pass
log.debug(f"favorite() unimplemented!")

def unfavorite():
# project_id: int, user_id: int):
pass
log.debug(f"unfavorite() unimplemented!")

def get_project_title():
# project_id: int, preferred_locale: str = "en") -> str:
pass
log.debug(f"get_project_title() unimplemented!")

def get_project_stats():
# project_id: int) -> ProjectStatsDTO:
pass
log.debug(f"get_project_stats() unimplemented!")

def get_project_user_stats():
# project_id: int, username: str) -> ProjectUserStatsDTO:
pass
log.debug(f"get_project_user_stats() unimplemented!")

def get_project_teams():
# project_id: int):
pass
log.debug(f"get_project_teams() unimplemented!")

def get_project_organisation():
# project_id: int) -> Organisation:
pass
log.debug(f"get_project_organisation() unimplemented!")

def send_email_on_project_progress():
# project_id):
pass
log.debug(f"send_email_on_project_progress() unimplemented!")

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down
Loading

0 comments on commit 10e048c

Please sign in to comment.