def test_configure(mock_pkg_resources, mock_driver_mgr, mock_plugin_mgr, config, mock_input, mock_getch): mockdriver = Mock() mockdriver.name = "testdriver" mockplugs = [Mock(), Mock(), Mock()] mockplugs[0].name = "test_process" mockplugs[1].name = "test_process2" mockplugs[2].name = "test_output" mock_pkg_resources.iter_entry_points.side_effect = [(mockdriver, ), mockplugs] # We need to mock out all methods that touch the filesystem config.config_dir = Mock(return_value='/tmp/foo') config.dump = Mock() mock_getch.return_value = " " mock_input.side_effect = ( "1", # Select device driver "1", # Select plugin 'test_output' "2", # Select plugin 'test_process' "", # Finish plugin selection "test_process", # Set processing pipeline "y", # Start setting target pages, "y", # Confirm focus setting ) mock_driver_mgr.return_value.driver.num_devices = 1 cli.configure(config) mock_driver_mgr.return_value.driver.num_devices = 2 assert config['driver'].get() == 'testdriver' assert config['plugins'].get() == ["test_process", "test_output"] assert config["device"]["focus_distance"].get() == 300 assert config.dump.called_once_with('/tmp/foo')
def test_configure(config, mock_input, mock_getch): config["plugins"] = [] # We need to mock out all methods that touch the filesystem config.config_dir = Mock(return_value='/tmp/foo') config.dump = Mock() mock_getch.return_value = " " mock_input.side_effect = ( "1", # Select device driver "1", # Select plugin 'test_output' "2", # Select plugin 'test_process' "", # Finish plugin selection "test_process", # Set processing pipeline "y", # Start setting target pages, "y", # Confirm focus setting ) TestDriver.num_devices = 1 cli.configure(config) TestDriver.num_devices = 2 print config['plugins'].get() assert config['driver'].get() == 'testdriver' assert config['plugins'].get() == ["test_process", "test_output"] assert config["device"]["focus_distance"].get() == 300 assert config.dump.called_once_with('/tmp/foo')
def test_configure(self): cli.getch = Mock(return_value=' ') cli.get_devices = Mock(side_effect=[[x] for x in self.devices]) cli.configure() assert cli.getch.call_count == 4 assert cli.get_devices.call_count == 2 assert self.devices[0].set_orientation.call_count == 1 assert self.devices[0].set_orientation.call_args_list == [call('left')] assert self.devices[1].set_orientation.call_count == 1 assert self.devices[1].set_orientation.call_args_list == ( [call('right')])
def test_configure(self): cli.getch = Mock(return_value=' ') cli.get_devices = Mock(side_effect=[[x] for x in self.devices]) cli.configure() assert cli.getch.call_count == 4 assert cli.get_devices.call_count == 2 assert self.devices[0].set_orientation.call_count == 1 assert self.devices[0].set_orientation.call_args_list == [call('left')] assert self.devices[1].set_orientation.call_count == 1 assert self.devices[1].set_orientation.call_args_list == ([ call('right') ])
def test_configure_nodevices(self): cli.getch = Mock(return_value=' ') cli.get_devices = Mock(return_value=[]) cli.configure()
def test_configure_twodevices(self): cli.getch = Mock(return_value=' ') cli.get_devices = Mock(return_value=self.devices) cli.configure()