Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ __pycache__/
mentors.csv
teams.csv
matching.csv
compatibility.csv
compatibility.csv
.vscode/
*.pyc
File renamed without changes.
File renamed without changes.
Empty file added mentor_matching/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions assign.py → mentor_matching/assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

print("Process started! Reading mentor file...", flush = True)
mentors = []
with open("mentors.csv") as mentorFile:
with open("data/mentors.csv") as mentorFile:
mentorReader = csv.reader(mentorFile)
# remove header rows, if any
for _ in range(utils.mentorHeaderRows):
Expand All @@ -22,7 +22,7 @@

print("Reading team file...", flush = True)
teams = []
with open("teams.csv") as teamFile:
with open("data/teams.csv") as teamFile:
teamReader = csv.reader(teamFile)
# remove header rows, if any
for _ in range(utils.teamHeaderRows):
Expand Down
36 changes: 36 additions & 0 deletions mentor_matching/mentor_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import csv
import unittest

from utils import Mentor


class TestParsingMentor(unittest.TestCase):
def test_from_string(self):
raw_csv_line = [
"Mavericl,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,,,Jessica,1,Inconvenient,Convenient,Convenient,Not possible,Not possible,Somewhat,Very Confident"
]
reader = csv.reader(raw_csv_line)
processed_line = next(reader)
mentor = Mentor(processed_line)

self.assertEqual(mentor.name, "Mavericl")
self.assertEqual(mentor.teamTypeRequests, [1, 1, 0, 0])
self.assertEqual(mentor.teamsRequested, [])
self.assertEqual(mentor.teamsRequired, [])
self.assertEqual(mentor.mentorsRequired, ["Jessica"])
self.assertEqual(mentor.comfortAlone, "1")
self.assertEqual(
mentor.transitConveniences,
[
"Inconvenient",
"Convenient",
"Convenient",
"Not possible",
"Not possible",
],
)
self.assertEqual(mentor.skillsConfidence, ["Somewhat", "Very Confident"])


if __name__ == "__main__":
unittest.main()
File renamed without changes.