generated from mwc/lab_weather
I am going to run the code to make sure no errors come as I accidently just did mwc submit rather than python test_friend_function.py
This commit is contained in:
@@ -98,7 +98,15 @@ def get_color_dict(people):
|
||||
"orange": 1,
|
||||
}
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
color_counts = {}
|
||||
for person in people:
|
||||
for color in person["favorite_colors"]:
|
||||
if color in color_counts:
|
||||
color_counts[color] += 1
|
||||
else:
|
||||
color_counts[color] = 1
|
||||
return color_counts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,52 +39,52 @@ from friend_functions import (
|
||||
# def test_returns_none_when_person_missing(self):
|
||||
# self.assertEqual(count_favorite_colors(family, "Ken Kesey"), None)
|
||||
|
||||
class TestPeopleWhoLikeColor(TestCase):
|
||||
def test_returns_correct_length(self):
|
||||
self.assertEqual(len(people_who_like_color(family, "blue")), 2)
|
||||
self.assertEqual(len(people_who_like_color(family, "purple")), 0)
|
||||
# class TestPeopleWhoLikeColor(TestCase):
|
||||
# def test_returns_correct_length(self):
|
||||
# self.assertEqual(len(people_who_like_color(family, "blue")), 2)
|
||||
# self.assertEqual(len(people_who_like_color(family, "purple")), 0)
|
||||
|
||||
def test_returns_full_dicts(self):
|
||||
result = people_who_like_color(family, "orange")
|
||||
self.assertEqual(len(result), 1)
|
||||
self.assertEqual(result[0]["email"], "auctor.odio@icloud.ca")
|
||||
# def test_returns_full_dicts(self):
|
||||
# result = people_who_like_color(family, "orange")
|
||||
# self.assertEqual(len(result), 1)
|
||||
# self.assertEqual(result[0]["email"], "auctor.odio@icloud.ca")
|
||||
|
||||
class TestCountPeopleWhoLikeColor(TestCase):
|
||||
def test_returns_correct_count(self):
|
||||
self.assertEqual(count_people_who_like_color(friends, "grey"), 2)
|
||||
self.assertEqual(count_people_who_like_color(friends, "beige"), 1)
|
||||
self.assertEqual(count_people_who_like_color(friends, "cornflower"), 0)
|
||||
# class TestCountPeopleWhoLikeColor(TestCase):
|
||||
# def test_returns_correct_count(self):
|
||||
# self.assertEqual(count_people_who_like_color(friends, "grey"), 2)
|
||||
# self.assertEqual(count_people_who_like_color(friends, "beige"), 1)
|
||||
# self.assertEqual(count_people_who_like_color(friends, "cornflower"), 0)
|
||||
|
||||
# class TestGetColorDict(TestCase):
|
||||
# def test_returns_correct_dict(self):
|
||||
# familyExpected = {
|
||||
# "aqua": 2,
|
||||
# "red": 2,
|
||||
# "blue": 2,
|
||||
# "black": 2,
|
||||
# "white": 1,
|
||||
# "grey": 1,
|
||||
# "yellow": 2,
|
||||
# "orange": 1,
|
||||
# }
|
||||
# friendsExpected = {
|
||||
# "lime": 1,
|
||||
# "grey": 2,
|
||||
# "sea foam": 1,
|
||||
# "aqua": 2,
|
||||
# "teal": 1,
|
||||
# "white": 1,
|
||||
# "red": 2,
|
||||
# "black": 2,
|
||||
# "blue": 2,
|
||||
# "tan": 1,
|
||||
# "sand": 1,
|
||||
# "green": 1,
|
||||
# "beige": 1,
|
||||
# "turquoise": 1,
|
||||
# "yellow": 2,
|
||||
# }
|
||||
# self.assertEqual(get_color_dict(family), familyExpected)
|
||||
# self.assertEqual(get_color_dict(friends), friendsExpected)
|
||||
class TestGetColorDict(TestCase):
|
||||
def test_returns_correct_dict(self):
|
||||
familyExpected = {
|
||||
"aqua": 2,
|
||||
"red": 2,
|
||||
"blue": 2,
|
||||
"black": 2,
|
||||
"white": 1,
|
||||
"grey": 1,
|
||||
"yellow": 2,
|
||||
"orange": 1,
|
||||
}
|
||||
friendsExpected = {
|
||||
"lime": 1,
|
||||
"grey": 2,
|
||||
"sea foam": 1,
|
||||
"aqua": 2,
|
||||
"teal": 1,
|
||||
"white": 1,
|
||||
"red": 2,
|
||||
"black": 2,
|
||||
"blue": 2,
|
||||
"tan": 1,
|
||||
"sand": 1,
|
||||
"green": 1,
|
||||
"beige": 1,
|
||||
"turquoise": 1,
|
||||
"yellow": 2,
|
||||
}
|
||||
self.assertEqual(get_color_dict(family), familyExpected)
|
||||
self.assertEqual(get_color_dict(friends), friendsExpected)
|
||||
|
||||
# main()
|
||||
|
||||
Reference in New Issue
Block a user