def test_get_map_size_after_set_map_size(self):
        """Test get_map_size if it returns valid value.

        The result is expected True
        """
        map.set_map_size(10)  # set map_size 10
        self.assertEqual(10, map.get_map_size())
Пример #2
0
    def test_set_map_size_with_positive_integer(self):
        """Test set_map_size with positive integer.

        The result is expected True
        """
        map.set_map_size(20)
        self.assertEqual(20, map.get_map_size())
    def test_draw_map_outline_length_of_list(self):
        """Test draw_map if it creates valid length of list based on map_size.

        The result is expected True
        """
        map.set_map_size(10)
        map_outline = map.draw_map_outline()
        self.assertEqual(10, len(map_outline))
    def test_draw_map_outline_type_of_return(self):
        """Test draw_map if it returns a list properly.

        The result is expected True
        """
        map.set_map_size(10)
        map_outline = map.draw_map_outline()
        self.assertEqual(list, type(map_outline))
    def test_show_map_key_error(self):
        """Test show_map if it raises KeyError when incomplete dictionary is given as argument.

        The result is expected True
        """
        with self.assertRaises(KeyError):
            map.set_map_size(3)
            map.show_map(self.no_row_dict)
Пример #6
0
    def test_set_map_size_with_zero(self, mock_stdout):
        """Test set_map_size with zero.

        The result is expected to print valid output
        """
        map.set_map_size(0)
        expected_output = "You must input positive integer.\n"
        self.assertEqual(mock_stdout.getvalue(), expected_output)
    def test_draw_map_outline_value_of_each_dict(self):
        """Test draw_map_outline if it contains valid value in each dictionary.

        The result is expected True
        """
        map.set_map_size(10)
        map_outline = map.draw_map_outline()
        map_value = map_outline[0][0, 0]
        self.assertEqual(' ', map_value)
    def test_draw_map_outline_type_of_elements(self):
        """Test draw_map if it contains valid dictionary elements.

        The result is expected True
        """
        map.set_map_size(10)
        map_outline = map.draw_map_outline()
        map_elements = map_outline[0]
        self.assertEqual(dict, type(map_elements))
    def test_draw_last_line_map_length_of_list(self):
        """Test draw_last_line_map if it returns valid length of list based on map_size.

        The result is expected True
        """
        map.set_map_size(5)
        map_outline = map.draw_map_outline()
        last_line = map.draw_last_line_map(map_outline)
        self.assertEqual(5, len(last_line))
    def test_draw_last_line_map_type_of_return(self):
        """Test draw_last_line_map if the type of return is valid.

        The result is expected True
        """
        map.set_map_size(5)
        map_outline = map.draw_map_outline()
        last_line = map.draw_last_line_map(map_outline)
        self.assertEqual(list, type(last_line))
    def test_draw_map_user_location(self):
        """Test draw_map if it writes the location of user properly.

        The result is expected True
        """
        map.set_map_size(3)
        map_lines = map.draw_map_outline()
        drawn_map = map.draw_map(map_lines, self.test_dict)
        self.assertEqual('[O]', drawn_map[2][2, 2])
    def test_draw_map_length_of_list(self):
        """Test draw_map if the length of returned list is valid.

        The result is expected True
        """
        map.set_map_size(3)
        map_lines = map.draw_map_outline()
        drawn_map = map.draw_map(map_lines, self.test_dict)
        self.assertEqual(3, len(drawn_map))
    def test_draw_map_type_of_return(self):
        """Test draw_map if it returns valid list.

        The result is expected True
        """
        map.set_map_size(3)
        map_lines = map.draw_map_outline()
        drawn_map = map.draw_map(map_lines, self.test_dict)
        self.assertEqual(list, type(drawn_map))
    def test_show_map_print_output(self, mock_stdout):
        """Test show_map if it prints valid output.

        The result is expected True
        """
        map.set_map_size(3)
        map.show_map(self.test_dict)
        expected_output = " ┌  ─  ┐ \n" \
                          " │ [O] │ \n" \
                          " └  ─  ┘ \n"
        self.assertEqual(mock_stdout.getvalue(), expected_output)
Пример #15
0
 def setUp(self):
     """Set the map_size to 8 for tests"""
     map.set_map_size(8)