def tearDown(self):
     """
     Delete the temporary database
     """
     temp = appInfo(0, 0, 0, "test")
     self.dao.deleteAppInfo(temp)
     del self.dao
    def testSelectAppInfo(self):
        """
        Test that we can select a container that exists in the database already
        """
        rc, msg = self.testInsertAppInfoSmoke()
        self.assertTrue(rc)

        a = appInfo(0, 0, 0, "test")
        rc, selectAppInfo = self.dao.selectAppInfo("test")
        self.assertTrue(rc)
        self.assertEqual(a.appInfoToList(), selectAppInfo.appInfoToList())
 def testInsertAppInfo(self):
     """
     Test that we can add a container that doesn't exist in the database
     """
     rc, msg = self.testInsertAppInfoSmoke()
     self.assertTrue(rc)
     """
     Check to see that the add went through
     """
     temp = appInfo(0, 0, 0, "test")
     rc, selectAppInfo = self.dao.selectAppInfo("test")
     self.assertTrue(rc)
     self.assertEqual(temp.appInfoToList(), selectAppInfo.appInfoToList())
Example #4
0
 def selectAppInfo(self, host):
     try:
         logging.info("Entering selectAppInfo")
         sql = "select * from appInfo where host = '" + host + "'"
         myresult = self.handleSQL(sql, True, None)
         if (myresult[0] == False):
             return myresult
         myresult = myresult[1][0]
         temp = appInfo(myresult[0], myresult[1], myresult[2], myresult[3])
         logging.info("selectAppInfo successful")
         return True, temp
     except Exception as e:
         logging.error("Error in selectAppInfo")
         logging.error(str(e))
         return self.handleError(e)
    def testDeleteContainer(self):
        """
        Test that we can delete a container from the database
        """
        rc, msg = self.testInsertAppInfoSmoke()
        self.assertTrue(rc)

        a = appInfo(0, 0, 0, "test")
        rc, deleteAppInfo = self.dao.deleteAppInfo(a)
        self.assertTrue(rc)
        """
        Verify that the container has actually been deleted.
        """
        rc, selectAppInfo = self.dao.selectAppInfo("test")
        self.assertFalse(rc)
    def testUpdateAppInfo(self):
        """
        Test that we can update a container in the database
        """
        a = appInfo(0, 0, 0, "test")
        rc, msg = self.dao.insertAppInfo(a)
        self.assertTrue(rc)

        a.major = a.major + 1
        rc, updateAppInfo = self.dao.updateAppInfo(a)
        self.assertTrue(rc)

        rc, temp = self.dao.selectAppInfo("test")
        self.assertTrue(rc)
        self.assertTrue(temp.major == a.major)
    def get_appinfos(self, apk_file_path):
        """
        反编译apk文件,获取apk信息

        :return:
        """
        app_info = appInfo().getInfo(apk_path=apk_file_path)
        if app_info and app_info.get('packageName'):
            return app_info
        else:
            tmp = os.popen('java -jar appInfo.jar %s' %
                           apk_file_path).readlines()
            print tmp
            for info in tmp:
                tmp_info = info.replace('\n', '').replace(' ', '').split(':')
                import urllib
                app_info[tmp_info[0]] = urllib.unquote(tmp_info[1])

        if app_info and app_info.get('packageName') and app_info.get(
                'mainActivity'):
            return app_info
        else:
            return None
 def testInsertAppInfoSmoke(self):
     a = appInfo(0, 0, 0, "test")
     return self.dao.insertAppInfo(a)