def test_line_valid_input(self): _paint_utils = PaintMain() _paint_utils._layout_matrix = _paint_utils.draw_layout(20,20) _layout = _paint_utils.draw_line(10,10,15,15) self.assertEqual(22, len(_layout)) print('Test Line with Valid inputs')
def test_draw_layout_wrong_input(self): _paint_utils = PaintMain() try: _paint_utils._layout_matrix = _paint_utils.draw('C 30r 30c') except ValueError as ex: self.assertIsInstance(ex,ValueError) print('Testing in input command for Layout with invalid input')
def test_layout_nagative_input(self): _paint_utils = PaintMain() try: _layout = _paint_utils.draw_layout(-100, -100) except ValueError as ex: self.assertIsInstance(ex, ValueError) print('Test Layout with negative inputs')
def test_layout_invalid_input(self): _paint_utils = PaintMain() try: _layout = _paint_utils.draw_layout(1000, 1000) except ValueError as ex: self.assertIsInstance(ex, ValueError) print('Test Layout wifht invalid inputs')
def __init__(self): self._paint_utils = None self.input_command = [] self._layout_matrix = [] self.MAX_WIDTH = 300 self.MAX_HEIGHT = 300 self._paint_utils = PaintMain(self.MAX_WIDTH, self.MAX_HEIGHT)
def test_line_nagative_input(self): _paint_utils = PaintMain() _paint_utils._layout_matrix = _paint_utils.draw_layout(20, 20) try: _layout = _paint_utils.draw_line(-100, -100, 15, 15) except ValueError as ex: self.assertIsInstance(ex, ValueError) print('Test Line with negative inputs')
def test_rect_invalid_input(self): _paint_utils = PaintMain() _paint_utils._layout_matrix = _paint_utils.draw_layout(20, 20) try: _layout = _paint_utils.draw_rectangle(100, 100, 15, 15) except ValueError as ex: self.assertIsInstance(ex, ValueError) print('Test Rectangle with invalid inputs')
class Painter: def __init__(self): self._paint_utils = None self.input_command = [] self._layout_matrix = [] self.MAX_WIDTH = 300 self.MAX_HEIGHT = 300 self._paint_utils = PaintMain(self.MAX_WIDTH, self.MAX_HEIGHT) print('Welcome to the Painter') def execute_command(self, input_cmd): try: self._layout_matrix = copy.deepcopy( self._paint_utils.execute_command(input_cmd)) self._paint_utils.render(self._layout_matrix) except ValueError as ex: print(str(ex))
def test_draw_rect(self): _paint_utils = PaintMain() _paint_utils._layout_matrix = _paint_utils.draw_layout(20, 20) _paint_utils._layout_matrix = _paint_utils.draw('R 1 1 20 20') self.assertEqual('X', _paint_utils._layout_matrix[20][20]) print('Testing in input command for Rectangle rendering proerly')
def test_draw_layout(self): _paint_utils = PaintMain() _paint_utils._layout_matrix = _paint_utils.draw('C 30 30') self.assertEqual(32, len(_paint_utils._layout_matrix)) print('Testing in input command for Layout rendering proerly')
def test_layout_valid_input(self): _paint_utils = PaintMain() _layout = _paint_utils.draw_layout(10,10) self.assertEqual(12, len(_layout)) print('Test Layout with Valid inputs')
def test_draw_line(self,i=1): _paint_utils = PaintMain() _paint_utils._layout_matrix = _paint_utils.draw_layout(20, 20) _paint_utils._layout_matrix = _paint_utils.draw('L 1 1 20 20') self.assertEqual('X', _paint_utils._layout_matrix[i][i]) print('Testing in input command for Line rendering proerly')