def test_display_decompilation_progress_shows_warnings_in_intermediate_phase( 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='File Information', part='Pre-Processing', description='Obtaining file information', completion=5, warnings=['warning1', 'warning2']), DecompilationPhase(name='Done', part=None, description='Done', completion=100, warnings=[]) ] displayer.display_decompilation_progress(d) self.assertEqual( self.stdout.getvalue(), """ ID -- Pre-Processing: Obtaining file information (5%)... [OK] Warning: warning1 Warning: warning2 Done (100%)... \n""".lstrip())
def test_two_phases_with_different_description_are_not_equal(self): phase1 = DecompilationPhase( name='NAME', part='PART', description='DESCRIPTION', completion=75, warnings=['some warning'] ) phase2 = DecompilationPhase( name='NAME', part='PART', description='OTHER DESCRIPTION', completion=75, warnings=['some warning'] ) self.assertNotEqual(phase1, phase2)
def test_two_phases_with_same_data_are_equal(self): phase1 = DecompilationPhase( name='NAME', part='PART', description='DESCRIPTION', completion=75, warnings=['some warning'] ) phase2 = DecompilationPhase( name='NAME', part='PART', description='DESCRIPTION', completion=75, warnings=['some warning'] ) self.assertEqual(phase1, phase2)
def test_arguments_passed_to_initializer_are_accessible(self): phase = DecompilationPhase( name='NAME', part='PART', description='DESCRIPTION', completion=75, warnings=['some warning'] ) self.assertEqual(phase.name, 'NAME') self.assertEqual(phase.part, 'PART') self.assertEqual(phase.description, 'DESCRIPTION') self.assertEqual(phase.completion, 75) self.assertEqual(phase.warnings, ['some warning'])
def test_repr_returns_correct_value(self): phase = DecompilationPhase( name='NAME', part='PART', description='DESCRIPTION', completion=75, warnings=['some warning'] ) self.assertEqual( repr(phase), ("retdec.decompilation.DecompilationPhase(name='NAME', " "part='PART', description='DESCRIPTION', completion=75, " "warnings=['some warning'])") )
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, warnings=[]) ] displayer.display_decompilation_progress(d) self.assertEqual( self.stdout.getvalue(), """ ID -- Waiting for resources (0%)... [FAIL] """.lstrip())