示例#1
0
    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")
示例#2
0
    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")
示例#3
0
    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")
示例#4
0
    def test_welcome_message(self):
        self.input_values = iter(['exit'])

        interface.main()

        assert self.output[0] == _OUTPUT_WELCOME, (
            "Did you print the welcome message?")
示例#5
0
    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?"
示例#6
0
    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?")
示例#7
0
    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")
示例#8
0
    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")
示例#9
0
    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?"
示例#10
0
    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.")
示例#11
0
    def test_show_empty(self):
        self.input_values = iter(['show', 'exit'])

        interface.main()

        assert self.output[1] == [], "Check the output for 'show' action"
示例#12
0
    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"
示例#13
0
    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"