def test_performs_correct_actions_when_only_api_key_and_input_file_are_given(self): main(['decompiler.py', '--api-key', 'API-KEY', 'prog.exe']) # Decompiler is instantiated with correct arguments. self.DecompilerMock.assert_called_once_with( api_url=DEFAULT_API_URL, api_key='API-KEY' ) # Decompilation is started with correct arguments. self.decompiler.start_decompilation.assert_called_once_with( input_file='prog.exe', mode=None, generate_archive=False ) # The tool waits until the decompilation is finished. decompilation = self.get_started_decompilation() self.assertEqual( len(decompilation.wait_until_finished.mock_calls), 1 ) # The generated HLL code is saved. decompilation.save_hll_code.assert_called_once_with(os.getcwd()) # The generated DSM code is saved. decompilation.save_dsm_code.assert_called_once_with(os.getcwd())
def test_does_not_save_output_compiled_binary_when_input_is_binary_file(self): main([ 'decompiler.py', '--api-key', 'API-KEY', 'file.exe' ]) decompilation = self.get_started_decompilation() self.assertFalse(decompilation.save_binary.called)
def test_saves_output_compiled_binary_when_input_is_c_file_uppercase_c(self): main([ 'decompiler.py', '--api-key', 'API-KEY', 'file.C' ]) decompilation = self.get_started_decompilation() decompilation.save_binary.assert_called_once_with(os.getcwd())
def call_main_with_standard_arguments_and(self, *additional_args): """Calls ``main()`` with standard arguments (such as ``--api-key``), but also includes `additional_args`. """ standard_args = ( 'decompiler.py', '--api-key', 'API-KEY', 'prog.exe' ) main(standard_args + additional_args)
def test_saves_output_compiled_binary_when_mode_is_c(self): main([ 'decompiler.py', '--api-key', 'API-KEY', '--mode', 'c', 'file' ]) decompilation = self.get_started_decompilation() decompilation.save_binary.assert_called_once_with(os.getcwd())
def test_performs_correct_actions_when_only_api_key_and_input_file_are_given( self): main(['decompiler.py', '--api-key', 'API-KEY', 'prog.exe']) # Decompiler is instantiated with correct arguments. self.DecompilerMock.assert_called_once_with(api_url=None, api_key='API-KEY') # Decompilation is started with correct arguments. self.decompiler.start_decompilation.assert_called_once_with( input_file='prog.exe') # The tool waits until the decompilation is finished. decompilation = self.get_started_decompilation() self.assertEqual(len(decompilation.wait_until_finished.mock_calls), 1) # The generated HLL code is saved. decompilation.save_hll_code.assert_called_once_with(os.getcwd()) # The generated DSM code is saved. decompilation.save_dsm_code.assert_called_once_with(os.getcwd())
def test_does_not_save_output_compiled_binary_when_input_is_binary_file( self): main(['decompiler.py', '--api-key', 'API-KEY', 'file.exe']) decompilation = self.get_started_decompilation() self.assertFalse(decompilation.save_binary.called)
def test_saves_output_compiled_binary_when_input_is_c_file_uppercase_c( self): main(['decompiler.py', '--api-key', 'API-KEY', 'file.C']) decompilation = self.get_started_decompilation() decompilation.save_binary.assert_called_once_with(os.getcwd())
def test_saves_output_compiled_binary_when_mode_is_c(self): main(['decompiler.py', '--api-key', 'API-KEY', '--mode', 'c', 'file']) decompilation = self.get_started_decompilation() decompilation.save_binary.assert_called_once_with(os.getcwd())
def call_main_with_standard_arguments_and(self, *additional_args): """Calls ``main()`` with standard arguments (such as ``--api-key``), but also includes `additional_args`. """ standard_args = ('decompiler.py', '--api-key', 'API-KEY', 'prog.exe') return main(standard_args + additional_args)