Esempio n. 1
0
    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())
Esempio n. 2
0
    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())
Esempio n. 3
0
    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())
Esempio n. 4
0
    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())
Esempio n. 5
0
    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())
Esempio n. 6
0
    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())