def test_display_decompilation_progress_shows_warnings_in_last_phase(self): displayer = ProgressLogDisplayer() d = mock.Mock(spec_set=Decompilation) d.id = 'ID' d.has_finished.return_value = True d.has_failed.return_value = True d.get_phases.return_value = [ DecompilationPhase(name='File Information', part='Pre-Processing', description='Obtaining file information', completion=5, warnings=['warning1', 'warning2']), ] displayer.display_decompilation_progress(d) self.assertEqual( self.stdout.getvalue(), """ ID -- Pre-Processing: Obtaining file information (5%)... [FAIL] Warning: warning1 Warning: warning2 """.lstrip())
def test_display_download_progress_displays_correct_value(self): displayer = ProgressLogDisplayer() displayer.display_download_progress('test.out.c') self.assertEqual(self.stdout.getvalue(), ('\nDownloading:\n' ' - test.out.c\n'))
def test_display_decompilation_progress_shows_warnings_in_last_phase(self): displayer = ProgressLogDisplayer() d = mock.Mock(spec_set=Decompilation) d.id = 'ID' d.has_finished.return_value = True d.has_failed.return_value = True d.get_phases.return_value = [ DecompilationPhase( name='File Information', part='Pre-Processing', description='Obtaining file information', completion=5, warnings=[ 'warning1', 'warning2' ] ), ] displayer.display_decompilation_progress(d) self.assertEqual( self.stdout.getvalue(), """ ID -- Pre-Processing: Obtaining file information (5%)... [FAIL] Warning: warning1 Warning: warning2 """.lstrip())
def test_display_decompilation_progress_displays_correct_value_failed_decompilation(self): displayer = ProgressLogDisplayer() d = mock.Mock(spec_set=Decompilation) d.id = 'ID' d.has_finished.return_value = True d.has_failed.return_value = True d.get_phases.return_value = [ DecompilationPhase( name='Waiting For Resources', part=None, description='Waiting for resources', completion=0, warnings=[] ) ] displayer.display_decompilation_progress(d) self.assertEqual( self.stdout.getvalue(), """ ID -- Waiting for resources (0%)... [FAIL] """.lstrip())
def test_display_decompilation_progress_displays_correct_value_successful_decompilation( self): displayer = ProgressLogDisplayer() d = mock.Mock(spec_set=Decompilation) d.id = 'ID' d.has_finished.return_value = True d.has_failed.return_value = False d.get_phases.return_value = [ DecompilationPhase(name='Waiting For Resources', part=None, description='Waiting for resources', completion=0), DecompilationPhase(name='File Information', part='Pre-Processing', description='Obtaining file information', completion=5), DecompilationPhase(name='Done', part=None, description='Done', completion=100) ] displayer.display_decompilation_progress(d) self.assertEqual( self.stdout.getvalue(), """ ID -- Waiting for resources (0%)... [OK] Pre-Processing: Obtaining file information (5%)... [OK] Done (100%)... \n""".lstrip())
def test_display_generation_failure_displays_correct_value(self): displayer = ProgressLogDisplayer() displayer.display_generation_failure('archive', 'Archive is too big.') self.assertEqual( self.stdout.getvalue(), 'Warning: Generation of the archive failed: Archive is too big.\n')
def test_display_download_progress_displays_correct_value(self): displayer = ProgressLogDisplayer() displayer.display_download_progress('test.out.c') self.assertEqual( self.stdout.getvalue(), ('\nDownloading:\n' ' - test.out.c\n') )
def test_display_decompilation_progress_displays_correct_value_successful_decompilation(self): displayer = ProgressLogDisplayer() d = mock.Mock(spec_set=Decompilation) d.id = 'ID' d.has_finished.return_value = True d.has_failed.return_value = False d.get_phases.return_value = [ DecompilationPhase( name='Waiting For Resources', part=None, description='Waiting for resources', completion=0, warnings=[] ), DecompilationPhase( name='File Information', part='Pre-Processing', description='Obtaining file information', completion=5, warnings=[] ), DecompilationPhase( name='Done', part=None, description='Done', completion=100, warnings=[] ) ] displayer.display_decompilation_progress(d) self.assertEqual( self.stdout.getvalue(), """ ID -- Waiting for resources (0%)... [OK] Pre-Processing: Obtaining file information (5%)... [OK] Done (100%)... \n""".lstrip())
def test_display_decompilation_progress_displays_correct_value_failed_decompilation( self): displayer = ProgressLogDisplayer() d = mock.Mock(spec_set=Decompilation) d.id = 'ID' d.has_finished.return_value = True d.has_failed.return_value = True d.get_phases.return_value = [ DecompilationPhase(name='Waiting For Resources', part=None, description='Waiting for resources', completion=0) ] displayer.display_decompilation_progress(d) self.assertEqual( self.stdout.getvalue(), """ ID -- Waiting for resources (0%)... [FAIL] """.lstrip())
def test_repr_returns_correct_value(self): displayer = ProgressLogDisplayer() self.assertEqual(repr(displayer), '<retdec.tools.decompiler.ProgressLogDisplayer>')