In [ ]:
""" Implement the patzer_greetings function """
import unittest
def patzer_greetings(list_of_greetings):
"""Create a function that returns True if the input list of strings
contains the word "Greetings". Otherwise, the function returns False.
"""
pass # TODO remove this line and implement the function
# Tests below
# You can look, but don't touch!
class PatzerGreetingsUnitTests(unittest.TestCase):
"""Test the patzer_greetings function"""
def test_returns_true_for_greeting(self):
inputs = ["Hey", "Hello", "Greetings", "Hola"]
self.assertTrue(patzer_greetings(inputs))
def test_returns_false_for_no_greetings(self):
inputs = ["Hey", "Hello", "Hola"]
self.assertFalse(patzer_greetings(inputs))
def test_returns_false_for_empty_list(self):
self.assertFalse(patzer_greetings([]))
def test_logic_is_lower_case_insensitive(self):
inputs = ["Hey", "Hello", "Greetings", "Hola"]
lower_inputs = list(map(lambda x: x.lower(), inputs))
self.assertTrue(patzer_greetings(lower_inputs))
def test_logic_is_upper_case_insensitive(self):
inputs = ["Hey", "Hello", "Greetings", "Hola"]
upper_inputs = list(map(lambda x: x.upper(), inputs))
self.assertTrue(patzer_greetings(upper_inputs))
suite = unittest.TestLoader().loadTestsFromTestCase(PatzerGreetingsUnitTests)
unittest.TextTestRunner().run(suite)
In [ ]: