示例#1
0
 def test_previous_image_first_image(self, mock_view):
     args = mock.Mock()
     args.input_dir = None
     model = Model(args)
     controller = Controller(model, mock_view)
     model.images = ["abc.png", "test.png", "ababaa.png"]
     model.current_file = 0
     controller.previous_image()
     self.assertEqual(0, model.current_file)
示例#2
0
 def test_next_image_last_image(self, mock_view):
     args = mock.Mock()
     args.input_dir = None
     model = Model(args)
     controller = Controller(model, mock_view)
     model.images = ["abc.png", "test.png", "ababaa.png"]
     model.current_file = 2
     controller.next_image()
     self.assertEqual(2, model.current_file)
示例#3
0
 def test_previous_image(self, mock_view, mock_load_image):
     args = mock.Mock()
     args.input_dir = None
     model = Model(args)
     controller = Controller(model, mock_view)
     model.images = ["abc.png", "test.png", "ababaa.png"]
     model.current_file = 1
     controller.previous_image()
     mock_load_image.assert_called_with = model.images[2]
     self.assertEqual(0, model.current_file)
示例#4
0
 def test_rotated_image(self, mock_display_image, mock_view):
     args = mock.Mock()
     args.input_dir = None
     model = Model(args)
     controller = Controller(model, mock_view)
     image = Image.new("RGB", (8, 4))
     model.current_image = image
     controller.rotate_image()
     rotated_image = mock_display_image.call_args[0][0]
     mock_display_image.assert_called()
     self.assertEqual(rotated_image.width, 4)
     self.assertEqual(rotated_image.height, 8)
示例#5
0
 def test_load_image(self, mock_view, mock_display_image, mock_image_open):
     args = mock.Mock()
     args.input_dir = None
     image_name = "test.jpg"
     model = Model(args)
     controller = Controller(model, mock_view)
     model.images = [image_name]
     args.input_dir = "/home/test/"
     img = Image.new("RGB", (8, 8))
     mock_image_open.return_value = img
     controller.load_image(image_name)
     mock_image_open.assert_called_with(
         os.path.join(args.input_dir, image_name))
     mock_display_image.assert_called_with(img)
     mock_view.set_title.assert_called_with("({0}/{1}): {2}".format(
         model.current_file + 1, len(model.images), image_name))
示例#6
0
文件: inbac.py 项目: weclaw1/inbac
    def __init__(self, args: Namespace, master: Tk):
        self.model: Model = Model(args)
        self.view: View = View(master, args.window_size)

        if args.input_dir is None:
            args.input_dir = filedialog.askdirectory(parent=master)
        args.output_dir = getattr(
            args, "output_dir", os.path.join(args.input_dir, "crops"))

        self.controller: Controller = Controller(self.model, self.view)

        self.view.controller = self.controller