Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guinslym committed Nov 19, 2024
1 parent da47526 commit 9bc7556
Showing 1 changed file with 52 additions and 7 deletions.
59 changes: 52 additions & 7 deletions tests/test_schools.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,56 @@
from ask_schools import __version__
from ask_schools import find_school_by_operator_suffix
import pytest
from sp_ask_school import (
find_school_by_operator_suffix,
find_queues_from_a_school_name,
find_school_by_queue_or_profile_name,
find_queue_by_criteria,
sp_ask_school_dict
)

def test_find_school_by_operator_suffix():
assert find_school_by_operator_suffix("nalini_tor") == "toronto"
assert find_school_by_operator_suffix("librarian_west") == "Western"
assert find_school_by_operator_suffix("user_mac") == "McMaster"
assert find_school_by_operator_suffix(None) == None
# Test cases for usernames without valid suffixes
assert find_school_by_operator_suffix("novalidformat") == "Unknown"
assert find_school_by_operator_suffix("guelph-librarian1") == "Guelph"
assert find_school_by_operator_suffix("admin-toronto") == "admin"

def test_version():
assert __version__ == "0.1.0"
def test_find_queues_from_a_school_name():
toronto_queues = [
"toronto",
"toronto-mississauga",
"toronto-scarborough",
"toronto-st-george",
"toronto-st-george-proactive",
]
assert find_queues_from_a_school_name("Toronto") == toronto_queues
assert find_queues_from_a_school_name("Invalid") == "Unknown"
assert find_queues_from_a_school_name(None) == None

def test_find_school_by_queue_or_profile_name():
assert find_school_by_queue_or_profile_name("western-proactive") == "Western"
assert find_school_by_queue_or_profile_name("toronto-st-george") == "toronto"
assert find_school_by_queue_or_profile_name("invalid-queue") == "Unknown"
assert find_school_by_queue_or_profile_name(None) == None

def check_school_name_equal_toronto():
result = find_school_by_operator_suffix("_tor")
assert result == "Tordonto"
def test_find_queue_by_criteria():
french_queues = find_queue_by_criteria("-fr")
assert "ottawa-fr" in french_queues
assert "western-fr" in french_queues

txt_queues = find_queue_by_criteria("-txt")
assert "carleton-txt" in txt_queues
assert "mcmaster-txt" in txt_queues

# Test edge cases
assert find_queue_by_criteria(None) == []
assert find_queue_by_criteria("nonexistent") == []

def test_data_integrity():
required_fields = ["id", "queues", "suffix", "short_name", "full_name"]
for item in sp_ask_school_dict:
school = item["school"]
for field in required_fields:
assert field in school, f"Missing field {field} in school {school.get('short_name', 'unknown')}"

0 comments on commit 9bc7556

Please sign in to comment.