def test_list_commands(self): """Invoking with --list-cmds must not raise an error""" with capture_stdout() as out: self.assertEqual(gbp.scripts.supercommand.supercommand(['argv0', '--list-cmds']), 0) for cmd in ['import-orig', 'create-remote-repo', 'pq']: self.assertIn("%s - " % cmd, out.output())
def test_list_commands(self): """Invoking with --list-cmds must not raise an error""" with capture_stdout() as out: self.assertEqual( gbp.scripts.supercommand.supercommand(['argv0', '--list-cmds']), 0) for cmd in ['import-orig', 'create-remote-repo', 'pq']: self.assertIn("%s - " % cmd, out.output())
def test_show_types(self): types = [] for i in range(3): type_ = mock.MagicMock() type_.title = f'Test{i}' type_.page_width = i**2 * 100 type_.page_height = i**3 * 100 types.append(type_) output = testutils.capture_stdout(self.view.show_types, types) for i in range(3): self.assertIn(f'Test{i}', output) size = '{}x{}mm'.format(str(i**2 * 100), str(i**3 * 100)) self.assertIn(size, output) # No types output = testutils.capture_stdout(self.view.show_types, []) self.assertIn('No types found', output)
def test_show_notebooks(self): notebooks = [] for i in range(3): notebook = mock.MagicMock() notebook.title = f'Test{i}' notebook.total_pages = i**2 notebook.type = mock.MagicMock() notebook.type.title = 'Test Type' notebooks.append(notebook) output = testutils.capture_stdout(self.view.show_notebooks, notebooks) for i in range(3): self.assertIn(f'Test{i}', output) self.assertIn(str(i**2), output) self.assertIn('Test Type', output) # No notebooks output = testutils.capture_stdout(self.view.show_notebooks, []) self.assertIn('No notebooks found', output)
def test_show_separator(self): output = testutils.capture_stdout(self.view.show_separator) self.assertEqual(output, '----------------------------------------\n')
def test_show_info(self): message = 'Test message' output = testutils.capture_stdout(self.view.show_info, message) self.assertEqual(output, f'{message}\n')