def testNewZipWithNewFile(self):
     from androguard.core.bytecodes.apk import APK
     try:
         from unittest.mock import patch, MagicMock
     except:
         from mock import patch, MagicMock
     a = APK("examples/tests/a2dp.Vol_137.apk", testzip=True)
     with patch('zipfile.ZipFile') as zipFile:
         mockZip = MagicMock()
         zipFile.return_value=mockZip
         a.new_zip("testout.apk", new_files={'res/menu/menu.xml': 'content'})
         self.assertEqual(mockZip.writestr.call_count, 48)
         self.assertTrue(mockZip.close.called)
예제 #2
0
 def testNewZipWithNewFile(self):
     from androguard.core.bytecodes.apk import APK
     try:
         from unittest.mock import patch, MagicMock
     except:
         from mock import patch, MagicMock
     a = APK("examples/tests/a2dp.Vol_137.apk", testzip=True)
     with patch('zipfile.ZipFile') as zipFile:
         mockZip = MagicMock()
         zipFile.return_value=mockZip
         a.new_zip("testout.apk", new_files={'res/menu/menu.xml': 'content'})
         self.assertTrue(mockZip.writestr.call_count == 48)
         self.assertTrue(mockZip.close.called)
예제 #3
0
 def testNewZipWithoutModification(self):
     from androguard.core.bytecodes.apk import APK
     try:
         from unittest.mock import patch, MagicMock
     except:
         from mock import patch, MagicMock
     a = APK("examples/tests/a2dp.Vol_137.apk", testzip=True)
     with patch('zipfile.ZipFile') as zipFile:
         mockZip = MagicMock()
         zipFile.return_value = mockZip
         a.new_zip("testout.apk")
         self.assertTrue(mockZip.writestr.call_count == 48)
         self.assertTrue(mockZip.close.called)
예제 #4
0
 def testNewZipWithoutModification(self):
     from androguard.core.bytecodes.apk import APK
     try:
         from unittest.mock import patch, MagicMock
     except:
         from mock import patch, MagicMock
     a = APK("examples/tests/a2dp.Vol_137.apk", testzip=True)
     with patch('zipfile.ZipFile') as zipFile:
         mockZip = MagicMock()
         zipFile.return_value=mockZip
         a.new_zip("testout.apk")
         self.assertEqual(mockZip.writestr.call_count, 48)
         self.assertTrue(mockZip.close.called)