def test_add_item(self): self.input_values = iter(['add', 'tomatoes', '6', 'exit']) interface.main() assert self.prompts[1] == _PROMPT_ADD_ITEM, ( "Check your prompt message for adding an item")
def test_select_quantity(self): self.input_values = iter(['add', 'tomatoes', '6', 'exit']) interface.main() assert self.prompts[2] == _PROMPT_QUANTITY, ( "Check your prompt message for selecting quantity")
def test_first_prompt_message(self): self.input_values = iter(['exit']) interface.main() assert self.prompts[0] == _PROMPT_ACTION, ( "The message of your first prompt is incorrect")
def test_welcome_message(self): self.input_values = iter(['exit']) interface.main() assert self.output[0] == _OUTPUT_WELCOME, ( "Did you print the welcome message?")
def test_list_after_adding_item(self): self.input_values = iter(['add', 'tomatoes', '6', 'exit']) interface.main() expected = [(6, 'tomatoes')] assert self.output[1] == expected, "Did you correctly build the list?"
def test_remove_non_existing_item(self): self.input_values = iter([ 'add', 'tomatoes', '6', 'remove', 'bananas', '2', 'exit']) interface.main() assert self.output[2] == _OUTPUT_ITEM_NOT_IN_LIST.format('bananas'), ( "Did you correctly build the list?")
def test_remove_item(self): self.input_values = iter([ 'add', 'tomatoes', '6', 'remove', 'tomatoes', '2', 'exit']) interface.main() expected = [(4, 'tomatoes')] assert self.output[2] == expected, ( "When you remove an existing item, update its quantity")
def test_not_sorted_after_sort(self): self.input_values = iter([ 'add', 'tomatoes', '6', 'add', 'bananas', '8', 'sort', 'y', 'show', 'exit'] ) interface.main() expected = [(6, 'tomatoes'), (8, 'bananas')] assert self.output[4] == expected, ( "When you sort, don't modify the list")
def test_sort_descending(self): self.input_values = iter([ 'add', 'tomatoes', '6', 'add', 'bananas', '8', 'sort', 'y', 'exit'] ) interface.main() expected = [(8, 'bananas'), (6, 'tomatoes')] assert self.output[3] == expected, "Did you correctly sort the list?"
def test_add_second_item(self): self.input_values = iter([ 'add', 'tomatoes', '6', 'add', 'bananas', '8', 'exit'] ) interface.main() expected = [(6, 'tomatoes'), (8, 'bananas')] assert self.output[2] == expected, ( "Make sure you append to the list when adding a new element.")
def test_show_empty(self): self.input_values = iter(['show', 'exit']) interface.main() assert self.output[1] == [], "Check the output for 'show' action"
def test_it_prompts(self): self.input_values = iter(['exit']) interface.main() assert len(self.prompts) > 0, "You need to prompt the user to action"
def test_show_list_after_adding_an_item(self): self.input_values = iter(['add', 'tomatoes', '6', 'exit']) interface.main() assert len(self.output) >= 1, "After adding an item, show the list"