def testDBError(self): serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_write_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_user_write_data_topic NOT FOUND ERROR") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, writeDataSrv) req = writeDataSrv() req.req_cols = [ ] #[String(data="model_str"),String(data="manufacturer"),String(data="version"),String(data="arch"),String(data="os"),String(data="picture")] #req.req_cols=[String("id"),String("macddr"), String("model"),String("owner"), String("timestamp")] req.req_cols = ["idsd", "macddr", "model", "owner", "timestamp"] entry1 = StringArrayMsg() #entry1=[string("'3'"),string("'1800000'"), string("'1'"),string("'1'"), string("'2014-11-23 09:04:13'")] entry1 = ["'3'", "'1800000'", "'1'", "'25'", "'2014-11-23 09:04:13'"] entry2 = StringArrayMsg() #entry2=[string("'4'"),string("'1900000'"), string("'1'"),string("'1'"), string("'2014-11-23 07:04:13'")] entry2 = ["'4'", "'1900000'", "'1'", "'25'", "'2014-11-23 07:04:13'"] req.req_data = [StringArrayMsg(s=entry1), StringArrayMsg(s=entry2)] response = db_service(req.req_cols, req.req_data) self.assertEqual( response.trace[0], "Database Error 1054: Unknown column 'idsd' in 'field list'") self.assertFalse(response.success.data)
def speech_to_text_callback(self, req): res = SpeechToTextSrvResponse() if req.language == '': res.error = 'No language specified' return res # Getting the results in order to parse them try: transcripts = self.speech_to_text(\ req.filename,\ req.user,\ req.audio_type,\ req.language) #print transcripts except RappError as e: res.error = e.value return res if len(transcripts['result']) == 0: return res # The alternative results alternatives = transcripts['result'][0]['alternative'] res = SpeechToTextSrvResponse() # If alternatives is 0 returns void response if len(alternatives) > 0: # The first alternative is Google's suggestion words = alternatives[0]['transcript'].split(" ") for w in words: res.words = res.words + [w] # Google provides the confidence for the first suggestion if 'confidence' in alternatives[0].keys(): res.confidence.data = alternatives[0]['confidence'] else: res.confidence.data = 0 for alt in alternatives[1:]: sam = StringArrayMsg() words = alt['transcript'].split(" ") for w in words: sam.s = sam.s + [w] res.alternatives = res.alternatives + [sam] else: res.confidence.data = 0 return res
def speech_to_text_callback(self, req): res = SpeechToTextSrvResponse() if req.language == '': res.error = 'No language specified' return res # Getting the results in order to parse them try: transcripts = self.speech_to_text(\ req.filename,\ req.user,\ req.audio_type,\ req.language) #print transcripts except RappError as e: res.error = e.value return res if len(transcripts['result']) == 0: return res # The alternative results alternatives = transcripts['result'][0]['alternative'] res = SpeechToTextSrvResponse() # If alternatives is 0 returns void response if len(alternatives) > 0: # The first alternative is Google's suggestion words = alternatives[0]['transcript'].split(" ") for w in words: res.words = res.words + [w] # Google provides the confidence for the first suggestion if 'confidence' in alternatives[0].keys(): res.confidence.data = alternatives[0]['confidence'] else: res.confidence.data = 0 for alt in alternatives[1:]: sam = StringArrayMsg() words = alt['transcript'].split(" ") for w in words: sam.s = sam.s + [w] res.alternatives = res.alternatives + [sam] else: res.confidence.data = 0 return res
def fetchData(self, req, tblName): try: res = fetchDataSrvResponse() db_username, db_password = self.getLogin() con = mdb.connect('localhost', db_username, db_password, 'RappStore') cur = con.cursor() returncols = self.constructCommaColumns(req.req_cols) where = self.constructAndQuery(req.where_data) query = "SELECT " + returncols + " FROM " + tblName + where cur.execute(query) result_set = cur.fetchall() for i in range(len(result_set)): line = StringArrayMsg() for j in range(len(result_set[i])): temp_s = String(result_set[i][j]) line.s.append((str(result_set[i][j]))) res.res_data.append(line) con.close() if (returncols == "*"): res.res_cols = self.getTableColumnNames(tblName) else: res.res_cols = req.req_cols res.success.data = True res.trace.append("Success") except mdb.Error, e: res.trace.append( ("Database Error %d: %s" % (e.args[0], e.args[1]))) res.success.data = False print "Error %d: %s" % (e.args[0], e.args[1])
def whatRappsCanRun(self,req,tblName): #generic db read function try: res = whatRappsCanRunSrvResponse() db_username,db_password=self.getLogin() con = mdb.connect('localhost', db_username, db_password, 'RappStore'); cur = con.cursor() #returncols=self.constructCommaColumns(req.req_cols) #print returncols #where=self.constructAndQuery(req.where_data) #print where #query="SELECT "+returncols+" FROM "+tblName+where query="SELECT rapp_id from tblRappsModelsVersion where model_id='"+req.model_id+"' and minimum_coreagent_version<='"+req.core_agent_version+"'"; #print "fetch called" cur.execute(query) result_set = cur.fetchall() for i in range(len(result_set)): line=StringArrayMsg() for j in range(len(result_set[i])): temp_s=String(result_set[i][j]) line.s.append((str(result_set[i][j])))#=line.s+[String(data=temp_s)] res.res_data.append(line) con.close() res.success.data=True res.trace.append("Success") except mdb.Error, e: res.trace.append(("Database Error %d: %s" % (e.args[0],e.args[1]))) res.success.data=False print "Error %d: %s" % (e.args[0],e.args[1])
def setNoiseProfile(self, req): res = AudioProcessingSetNoiseProfileSrvResponse() #-------------------------Check with database-------------------------# authentication_service = rospy.ServiceProxy(self.serv_db_topic, fetchDataSrv) req_db = fetchDataSrv() req_db.req_cols=["username"] entry1=["username", req.user] req_db.where_data=[StringArrayMsg(s=entry1)] resp = authentication_service(req_db.req_cols, req_db.where_data) if resp.success.data != True or len(resp.res_data) == 0: res.success = "false" res.error = "Non authenticated user" return res #-------------------------set noise profile-------------------------# ret = self.set_noise_profile_module.setNoise_profile(\ req.user,\ req.noise_audio_file,\ req.audio_file_type) if ret == 'true': res.success = ret res.error = '' else: res.success = 'false' res.error = ret return res
def getUserLanguage(self, username, res): serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_fetch_data_topic') knowrob_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) fetchDataSrvReq = fetchDataSrvRequest() fetchDataSrvReq.req_cols = ["language"] fetchDataSrvReq.where_data = [StringArrayMsg(s=["username", username])] fetchDataSrvResponse = knowrob_service(fetchDataSrvReq) if (fetchDataSrvResponse.success.data != True): res.trace.extend(fetchDataSrvResponse.trace) res.error = fetchDataSrvResponse.trace[0] res.success = False return True, "" return False, fetchDataSrvResponse.res_data[0].s[0]
def testNullInputError(self): serv_topic = rospy.get_param( 'rapp_mysql_wrapper_robot_fetch_data_topic') if (not serv_topic): rospy.logerror("mysql_wrapper_robot_read_data_topic") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = [] entry1 = [] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "IndexError: list index out of range") self.assertFalse(response.success.data)
def retrieveDataFromTestXml(self, finalTestFilePath, res, userLanguage): tree = ET.parse(finalTestFilePath) root = tree.getroot() res.testType = root.find("testType").text.encode('UTF-8') res.testSubType = root.find("testSubType").text.encode('UTF-8') language = root.find('Languages') for question in language.find(userLanguage): res.questions.append(question.find("body").text.encode('UTF-8')) res.correctAnswers.append( question.find("correctAnswer").text.encode('UTF-8')) line = StringArrayMsg() for answers in question.findall('answer'): line.s.append(answers.find("body").text.encode('UTF-8')) res.answers.append(line)
def testNullInputError(self): serv_topic = rospy.get_param( 'rapp_mysql_wrapper_robot_fetch_data_topic') if (not serv_topic): rospy.logerror("mysql_wrapper_robot_read_data_topic") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = [] entry1 = [] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual( response.trace[0], "Wrong Query Input Format, check for empty required columns list or wrong/incomplete Query data format" ) self.assertFalse(response.success.data)
def retrieveDataFromTestXml(self, testFilePath, userLanguage, res): rospack = rospkg.RosPack() testFilePath = rospack.get_path( 'rapp_cognitive_exercise') + testFilePath tree = ET.parse(testFilePath) root = tree.getroot() res.testType = root.find("testType").text.encode('UTF-8') res.testSubType = root.find("testSubType").text.encode('UTF-8') res.test = root.find("name").text.encode('UTF-8') language = root.find('Languages') for question in language.find(userLanguage): res.questions.append(question.find("body").text.encode('UTF-8')) res.correctAnswers.append( question.find("correctAnswer").text.encode('UTF-8')) line = StringArrayMsg() for answers in question.findall('answer'): line.s.append(answers.find("body").text.encode('UTF-8')) res.answers.append(line)
def whatRappsCanRun(self,req,tblName): try: res = whatRappsCanRunSrvResponse() db_username,db_password=self.getLogin() con = mdb.connect('localhost', db_username, db_password, 'RappStore'); cur = con.cursor() query="SELECT rapp_id from tblRappsModelsVersion where model_id='"+req.model_id+"' and minimum_coreagent_version<='"+req.core_agent_version+"'"; cur.execute(query) result_set = cur.fetchall() for i in range(len(result_set)): line=StringArrayMsg() for j in range(len(result_set[i])): temp_s=String(result_set[i][j]) line.s.append((str(result_set[i][j]))) res.res_data.append(line) con.close() res.success.data=True res.trace.append("Success") except mdb.Error, e: res.trace.append(("Database Error %d: %s" % (e.args[0],e.args[1]))) res.success.data=False res.error="Error %d: %s" % (e.args[0],e.args[1])
def speechRecognitionBatch(self, req): total_res = SpeechRecognitionSphinx4TotalSrvResponse() #-------------------------Check with database-------------------------# if self.use_db_authentication == True: req_db = fetchDataSrv() req_db.req_cols = ["username"] entry1 = ["username", req.user] req_db.where_data = [StringArrayMsg(s=entry1)] resp = self.authentication_service(req_db.req_cols, req_db.where_data) if resp.success.data != True or len(resp.res_data) == 0: total_res.error = "Non authenticated user" return total_res conf_req = SpeechRecognitionSphinx4ConfigureSrvRequest() spee_req = SpeechRecognitionSphinx4SrvRequest() conf_req.language = req.language conf_req.words = req.words conf_req.grammar = req.grammar conf_req.sentences = req.sentences conf_res = SpeechRecognitionSphinx4ConfigureSrvResponse() conf_res = self.configureSpeechRecognition(conf_req) total_res.error = conf_res.error if conf_res.error != '': total_res.error = total_res.error + '\n' + conf_res.error return total_res spee_req.path = req.path spee_req.audio_source = req.audio_source spee_req.user = req.user spee_res = self.speechRecognition(spee_req) total_res.words = spee_res.words total_res.error = spee_res.error return total_res
def chooserFunction(self, req): currentTimestamp = int(time.time()) #15552000000 for last 3 months try: res = testSelectorSrvResponse() #obtain user's ontology alias. It will be created if it does not exist in case of invalid username it will be caught serv_topic = rospy.get_param( 'rapp_knowrob_wrapper_create_ontology_alias') if (not serv_topic): rospy.logerror( "rapp_knowrob_wrapper_create_ontology_alias param not found" ) res.trace.append( "rapp_knowrob_wrapper_create_ontology_alias param not found" ) res.error = "rapp_knowrob_wrapper_create_ontology_alias param not found" res.success = False return res rospy.wait_for_service(serv_topic) knowrob_service = rospy.ServiceProxy(serv_topic, createOntologyAliasSrv) createOntologyAliasReq = createOntologyAliasSrvRequest() createOntologyAliasReq.username = req.username createOntologyAliasResponse = knowrob_service( createOntologyAliasReq) if (createOntologyAliasResponse.success != True): res.trace.extend(createOntologyAliasResponse.trace) res.error = createOntologyAliasResponse.error res.success = False return res #get user language serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_fetch_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_user_fetch_data_topic param not found") res.trace.append( "rapp_mysql_wrapper_user_fetch_data_topic param not found") res.error = "mysql_wrapper_rapp_read_data topic param not found" res.success = False return res rospy.wait_for_service(serv_topic) knowrob_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) fetchDataSrvReq = fetchDataSrvRequest() fetchDataSrvReq.req_cols = ["language"] fetchDataSrvReq.where_data = [ StringArrayMsg(s=["username", req.username]) ] #print fetchDataSrvReq.where_data fetchDataSrvResponse = knowrob_service(fetchDataSrvReq) if (fetchDataSrvResponse.success.data != True): #print fetchDataSrvResponse.res_data[0].s[0]; res.trace.extend(fetchDataSrvResponse.trace) res.error = fetchDataSrvResponse.trace[0] res.success = False return res userLanguage = fetchDataSrvResponse.res_data[0].s[0] #print userLanguage # #Check if test type exists (if a test type is provided) serv_topic = rospy.get_param( 'rapp_knowrob_wrapper_subclasses_of_topic') if (not serv_topic): rospy.logerror( "rapp_knowrob_wrapper_subclasses_of_topic topic param not found" ) res.trace.append( "rapp_knowrob_wrapper_subclasses_of_topic topic param not found" ) res.error = "rapp_knowrob_wrapper_subclasses_of_topic topic param not found" res.success = False return res rospy.wait_for_service(serv_topic) knowrob_service = rospy.ServiceProxy(serv_topic, ontologySubSuperClassesOfSrv) testTypesReq = ontologySubSuperClassesOfSrvRequest() testTypesReq.ontology_class = "CognitiveTests" testTypesResponse = knowrob_service(testTypesReq) if (testTypesResponse.success != True): res.trace.extend(testTypesResponse.trace) res.trace.append("cannot load test categories from ontology") res.error = testTypesResponse.error + "cannot load test categories from ontology" res.success = False return res testTypesList = [] for s in testTypesResponse.results: #res.trace.append(s) tmpList = s.split('#') testTypesList.append(tmpList[1]) serv_topic = rospy.get_param( 'rapp_knowrob_wrapper_user_performance_cognitve_tests') if (not serv_topic): rospy.logerror( "rapp_knowrob_wrapper_user_performance_cognitve_tests topic not foud" ) res.trace.append( "mysql_wrapper_rapp_read_data topic param not found") res.error = "mysql_wrapper_rapp_read_data topic param not found" res.success = False return res if (req.testType == ""): res.trace.append( "no test type provided, will use least recently used") noRecordsList = [] d1 = OrderedDict() for s in testTypesList: userPerformanceReq = userPerformanceCognitveTestsSrvRequest( ) userPerformanceReq.test_type = s userPerformanceReq.ontology_alias = createOntologyAliasResponse.ontology_alias knowrob_service = rospy.ServiceProxy( serv_topic, userPerformanceCognitveTestsSrv) userPerformanceResponse = knowrob_service( userPerformanceReq) if (userPerformanceResponse.success != True): noRecordsList.append(s) else: tmpUserPerfOrganizedByTimestamp = self.organizeUserPerformance( userPerformanceResponse) t1 = tmpUserPerfOrganizedByTimestamp.items()[0][0] d1[t1] = [s] if (len(noRecordsList) > 0): req.testType = random.choice(noRecordsList) res.trace.append( "made random choice from the test types which were never used by the user, choice was: " + req.testType) else: d1 = OrderedDict(sorted(d1.items(), key=lambda t: t[0])) req.testType = d1.values()[0][0] res.trace.append( "all test types had performance records.. least recently used one was :" + req.testType) else: if (req.testType not in testTypesList): res.trace.append("testType provided does not exist") res.error = "testType provided does not exist" res.success = False return res # check if performance records exist for the selected test in order to determine the difficulty setting noUserPerformanceRecordsExist = False chosenDif = "1" userPerformanceReq = userPerformanceCognitveTestsSrvRequest() userPerformanceReq.test_type = req.testType userPerformanceReq.ontology_alias = createOntologyAliasResponse.ontology_alias knowrob_service = rospy.ServiceProxy( serv_topic, userPerformanceCognitveTestsSrv) userPerformanceResponse = knowrob_service(userPerformanceReq) if (userPerformanceResponse.success != True): res.trace.extend(userPerformanceResponse.trace) res.trace.append( "KnowRob wrapper returned no performance records for this user.. will start with a a difficulty setting of 1" ) noUserPerformanceRecordsExist = True else: userPerfOrganizedByTimestamp = self.organizeUserPerformance( userPerformanceResponse) for k, v in userPerfOrganizedByTimestamp.items(): if (currentTimestamp - k > 15552000000): del userPerfOrganizedByTimestamp[k] else: break userScore = self.calculateUserScore( userPerfOrganizedByTimestamp) res.trace.append("user score :" + str(userScore)) if (userScore == 0): chosenDif = "1" elif (userScore < 0.75 * 100): chosenDif = "1" elif (userScore < 0.75 * 2 * 100): chosenDif = "2" else: #(userScore>0.75*3*100) chosenDif = "3" res.trace.append("Chosen Diff :" + chosenDif) #Get cognitive tests of the selected type. serv_topic = rospy.get_param( 'rapp_knowrob_wrapper_cognitive_tests_of_type') if (not serv_topic): rospy.logerror( "rapp_knowrob_wrapper_cognitive_tests_of_type not found") res.trace.append( "rapp_knowrob_wrapper_cognitive_tests_of_type not found") res.error = "rapp_knowrob_wrapper_cognitive_tests_of_type not found" res.success = False return res cognitiveTestsOfTypeSrvReq = cognitiveTestsOfTypeSrvRequest() cognitiveTestsOfTypeSrvReq.test_type = req.testType cognitiveTestsOfTypeSrvReq.test_language = userLanguage knowrob_service = rospy.ServiceProxy(serv_topic, cognitiveTestsOfTypeSrv) cognitiveTestsOfTypeResponse = knowrob_service( cognitiveTestsOfTypeSrvReq) if (cognitiveTestsOfTypeResponse.success != True): res.trace.extend(cognitiveTestsOfTypeResponse.trace) res.error = cognitiveTestsOfTypeResponse.error res.success = False return res #print "after tests........." #Filter the tests according to the determined difficulty success, testsOfTypeOrdered = self.filterTestsbyDifficulty( cognitiveTestsOfTypeResponse, chosenDif, res) #If no test exists if (not success): #not len(testsOfTypeOrdered)>0): res.trace.append( "Error, no tests of type contained in the ontology... cannot proceed" ) res.error = "Error, no tests of type contained in the ontology... cannot proceed" res.success = False return res #Choose the least recently used test of the given test type and difficulty and obtain the path to the xml file finalTestname = "" finalTestFilePath = "" if (noUserPerformanceRecordsExist): #print "inside no records" finalTestname = random.choice(testsOfTypeOrdered.keys()) finalTest = testsOfTypeOrdered[finalTestname] finalTestFilePath = finalTest[0][0] else: testsOfTypeOrderedCopy = testsOfTypeOrdered.copy() for k, v in userPerfOrganizedByTimestamp.items(): if (v[0][0] in testsOfTypeOrderedCopy): del testsOfTypeOrderedCopy[v[0][0]] if (len(testsOfTypeOrderedCopy) > 0): finalTestname = random.choice( testsOfTypeOrderedCopy.keys()) finalTest = testsOfTypeOrderedCopy[finalTestname] finalTestFilePath = finalTest[0][0] else: finalTestname = userPerfOrganizedByTimestamp.values()[ len(userPerfOrganizedByTimestamp) - 1] finalTestname = finalTestname[0][0] finalTest = testsOfTypeOrdered[finalTestname] finalTestFilePath = finalTest[0][0] #Retrieve the name of the selected test tmpList = finalTestname.split('#') res.test = tmpList[1] #Parse the test xml file and retrieve the desired information rospack = rospkg.RosPack() localPackagePath = rospack.get_path('rapp_cognitive_exercise') finalTestFilePath = localPackagePath + finalTestFilePath res.trace.append(finalTestFilePath) self.retrieveDataFromTestXml(finalTestFilePath, res, userLanguage) res.language = userLanguage res.success = True except IndexError: res.trace.append( "Null pointer exception.. some argument was empty") res.error = "Null pointer exception.. some argument was empty" res.success = False #print "Wrong Query Input Format, check for empty required columns list or wrong/incomplete Query data format" except IOError: res.success = False res.trace.append("IO Error, cant open file or read data") res.error = "IO Error, cant open file or read data" return res
def testTblRobotWriteReadDeleteCheck(self): #Write serv_topic = rospy.get_param( 'rapp_mysql_wrapper_robot_write_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_robot_write_data_topic NOT FOUND ERROR") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, writeDataSrv) req = writeDataSrv() req.req_cols = [ ] #[String(data="model_str"),String(data="manufacturer"),String(data="version"),String(data="arch"),String(data="os"),String(data="picture")] #req.req_cols=[String("id"),String("macddr"), String("model"),String("owner"), String("timestamp")] req.req_cols = ["macddr", "model", "owner", "timestamp"] entry1 = StringArrayMsg() entry1 = ["'1800000'", "'1'", "'25'", "'2014-11-23 09:04:13'"] entry2 = StringArrayMsg() entry2 = ["'1900000'", "'1'", "'25'", "'2014-11-23 07:04:13'"] req.req_data = [StringArrayMsg(s=entry1), StringArrayMsg(s=entry2)] response = db_service(req.req_cols, req.req_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read what was written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_robot_fetch_data_topic') if (not serv_topic): rospy.logerror("mysql_wrapper_robot_read_data_topic") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["macddr"] entry1 = ["macddr", "1800000"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "1800000") #self.assertEqual(response.res_data[1].s[0].data,"extreme3") #Update written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_robot_update_data_topic') if (not serv_topic): rospy.logerror("mysql_wrapper_robot_update_data_topic") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, updateDataSrv) req = updateDataSrv() req.set_cols = ["timestamp='2014-11-23 09:04:13'"] entry1 = ["macddr", '1900000'] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.set_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read again serv_topic = rospy.get_param( 'rapp_mysql_wrapper_robot_fetch_data_topic') if (not serv_topic): rospy.logerror("mysql_wrapper_robot_fetch_data_topic") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["macddr", "model"] entry1 = ["timestamp", "2014-11-23 09:04:13"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "1800000") self.assertEqual(response.res_data[1].s[0], "1900000") #Delete updated serv_topic = rospy.get_param( 'rapp_mysql_wrapper_robot_delete_data_topic') if (not serv_topic): rospy.logerror("mysql_wrapper_robot_delete_data_topic") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, deleteDataSrv) req = deleteDataSrv() entry1 = ["timestamp", "2014-11-23 09:04:13"] entry2 = ["model", "1"] req.where_data = [StringArrayMsg(s=entry1), StringArrayMsg(s=entry2)] response = db_service(req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Check if it was deleted serv_topic = rospy.get_param( 'rapp_mysql_wrapper_robot_fetch_data_topic') if (not serv_topic): rospy.logerror("mysql_wrapper_robot_write_delete_topic") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["macddr", "model"] entry1 = ["timestamp", "2014-11-23 09:04:13"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertTrue((len(response.res_data) < 1))
def testTblUserWriteReadDeleteCheck(self): #Write serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_write_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_write_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, writeDataSrv) req = writeDataSrv() req.req_cols = [ "username", "firstname", "lastname", "email", "email_id", "ontology_alias", "pwd", "usrgroup", "created", "accessed", "enabled", "activation" ] #req.req_cols=["idsd","macddr", "model","owner", "timestamp"] entry1 = StringArrayMsg() entry1 = [ "'testingDB1'", "'testingDB1'", "'testingDB1'", "'test@test'", "NULL", "NULL", "'86'", "'0'", "'2014-15-15 18:01:34'", "'0000-00-00 00:00:00'", "'1'", "'555'" ] entry2 = StringArrayMsg() entry2 = [ "'testingDB2'", "'testingDB2'", "'testingDB1'", "'test@test'", "NULL", "NULL", "'86'", "'0'", "'2014-15-15 18:01:34'", "'0000-00-00 00:00:00'", "'1'", "'555'" ] req.req_data = [StringArrayMsg(s=entry1), StringArrayMsg(s=entry2)] response = db_service(req.req_cols, req.req_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read what was written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_fetch_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["firstname", "lastname"] entry1 = ["lastname", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "testingDB1") self.assertEqual(response.res_data[1].s[0], "testingDB2") #Update written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_update_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_update_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, updateDataSrv) req = updateDataSrv() req.set_cols = ["firstname='testingDB1'"] entry1 = ["firstname", "testingDB2"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.set_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read again serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_read_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["firstname", "lastname"] entry1 = ["firstname", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "testingDB1") self.assertEqual(response.res_data[1].s[0], "testingDB1") #Delete updated serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_delete_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_delete_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, deleteDataSrv) req = deleteDataSrv() entry1 = ["firstname", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Check if it was deleted serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_read_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["firstname", "lastname"] entry1 = ["firstname", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertTrue((len(response.res_data) < 1))
def testTblModelWriteReadDeleteCheck(self): #Write serv_topic = rospy.get_param( 'rapp_mysql_wrapper_model_write_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_model_write_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, writeDataSrv) req = writeDataSrv() req.req_cols = [ "model_str", "manufacturer", "version", "arch", "os", "picture" ] entry1 = StringArrayMsg() entry1 = [ "'testingDB1'", "'testingDB1'", "'10.1'", "'test'", "'test'", "'test'" ] entry2 = StringArrayMsg() entry2 = [ "'testingDB2'", "'testingDB1'", "'10.1'", "'test'", "'test'", "'test'" ] req.req_data = [StringArrayMsg(s=entry1), StringArrayMsg(s=entry2)] response = db_service(req.req_cols, req.req_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read what was written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_model_fetch_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_model_fetch_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["model_str", "manufacturer"] entry1 = ["manufacturer", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "testingDB1") self.assertEqual(response.res_data[1].s[0], "testingDB2") #Update written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_model_update_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_model_update_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, updateDataSrv) req = updateDataSrv() req.set_cols = ["model_str='testingDB3'"] entry1 = ["model_str", "testingDB2"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.set_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read again serv_topic = rospy.get_param( 'rapp_mysql_wrapper_model_fetch_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_model_read_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["model_str", "manufacturer"] entry1 = ["manufacturer", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[1], "testingDB1") self.assertEqual(response.res_data[1].s[1], "testingDB1") #Delete updated serv_topic = rospy.get_param( 'rapp_mysql_wrapper_model_delete_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_model_delete_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, deleteDataSrv) req = deleteDataSrv() entry1 = ["manufacturer", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Check if it was deleted serv_topic = rospy.get_param( 'rapp_mysql_wrapper_model_fetch_data_topic') if (not serv_topic): rospy.logerror( "rapp_mysql_wrapper_model_read_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["model_str", "manufacturer"] entry1 = ["model_str", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertTrue((len(response.res_data) < 1))
def speech_to_text(self, file_path, user, audio_file_type, language): # Check the user serv_db_topic = rospy.get_param("rapp_mysql_wrapper_user_fetch_data_topic") authentication_service = rospy.ServiceProxy(serv_db_topic, fetchDataSrv) req_db = fetchDataSrv() req_db.req_cols=["username"] entry1=["username", user] req_db.where_data=[StringArrayMsg(s=entry1)] resp = authentication_service(req_db.req_cols, req_db.where_data) if resp.success.data != True or len(resp.res_data) == 0: raise RappError("Non authenticated user") # Check if file exists if not os.path.isfile(file_path): raise RappError("Error: file " + file_path + ' not found') # Check if file is flac. If not convert it new_audio = file_path audio_trans_topic = rospy.get_param("rapp_audio_processing_transform_audio_topic") audio_transform_srv = rospy.ServiceProxy( audio_trans_topic, AudioProcessingTransformAudioSrv ) cleanup = [] transform_req = AudioProcessingTransformAudioSrvRequest() transform_req.source_type = audio_file_type transform_req.source_name = new_audio transform_req.target_type = 'wav' new_audio += '.wav' transform_req.target_name = new_audio transform_req.target_channels = 1 transform_req.target_rate = 16000 trans_response = audio_transform_srv( transform_req ) if trans_response.error != 'success': raise RappError( trans_response.error ) cleanup.append(new_audio) # Denoise if necessary prev_audio_file = new_audio next_audio_file = prev_audio_file if audio_file_type in ['nao_ogg', 'nao_wav_1_ch', 'nao_wav_4_ch']: denoise_topic = rospy.get_param("rapp_audio_processing_denoise_topic") energy_denoise_topic = \ rospy.get_param("rapp_audio_processing_energy_denoise_topic") denoise_service = rospy.ServiceProxy(\ denoise_topic, AudioProcessingDenoiseSrv) energy_denoise_service = rospy.ServiceProxy(\ energy_denoise_topic, AudioProcessingDenoiseSrv) manipulation = {} manipulation['sox_transform'] = False manipulation['sox_denoising'] = False manipulation['sox_channels_and_rate'] = False if audio_file_type == "headset": pass elif audio_file_type == "nao_ogg": manipulation['sox_transform'] = True manipulation['sox_denoising'] = True manipulation['sox_denoising_scale'] = 0.15 elif audio_file_type == "nao_wav_4_ch": manipulation['sox_channels_and_rate'] = True manipulation['sox_denoising'] = True manipulation['sox_denoising_scale'] = 0.15 elif audio_file_type == "nao_wav_1_ch": manipulation['sox_denoising'] = True manipulation['sox_denoising_scale'] = 0.15 manipulation['detect_silence'] = True manipulation['detect_silence_threshold'] = 0.25 # Check if sox_transform is needed if manipulation['sox_transform'] == True: next_audio_file += "_transformed.wav" command = "sox " + prev_audio_file + " " + next_audio_file com_res = os.system(command) if com_res != 0: raise RappError("Error: sox malfunctioned") cleanup.append(next_audio_file) prev_audio_file = next_audio_file if manipulation['sox_channels_and_rate'] == True: next_audio_file += "_mono16k.wav" command = "sox " + prev_audio_file + " -r 16000 -c 1 " + next_audio_file com_res = os.system(command) if com_res != 0: raise RappError("Error: sox malfunctioned") cleanup.append(next_audio_file) prev_audio_file = next_audio_file if manipulation['sox_denoising'] == True: next_audio_file = prev_audio_file + "_denoised.wav" den_request = AudioProcessingDenoiseSrvRequest() den_request.audio_file = prev_audio_file den_request.denoised_audio_file = next_audio_file den_request.audio_type = audio_file_type den_request.user = user den_request.scale = manipulation['sox_denoising_scale'] den_response = denoise_service(den_request) if den_response.success != "true": raise RappError("Error:" + den_response.success) cleanup.append(next_audio_file) prev_audio_file = next_audio_file # must implement a fallback function to clear redundant files # Transform to flac transform_req = AudioProcessingTransformAudioSrvRequest() transform_req.source_type = 'headset' transform_req.source_name = new_audio transform_req.target_type = 'flac' newer_audio = new_audio + '.flac' transform_req.target_name = newer_audio transform_req.target_channels = 1 transform_req.target_rate = 16000 trans_response = audio_transform_srv( transform_req ) cleanup.append(newer_audio) if trans_response.error != 'success': raise RappError( trans_response.error ) # Open the file with open(newer_audio, "r") as f: speech = f.read() url = "www.google.com" # Fix language if language == 'en': language = "en-US" elif language == 'gr': language = 'el' #NOTE - Thats a general usage key. They may disable it in the future. key = "AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw" path = "/speech-api/v2/recognize?lang=" + language + "&key=" + key headers = { "Content-type": "audio/x-flac; rate=22050" }; params = {"xjerr": "1", "client": "chromium"} conn = httplib.HTTPSConnection(url) conn.request("POST", path, speech, headers) response = conn.getresponse() data = response.read() initial_data = data # Google returns one empty result for some reason here. Removing it.. index = data.find("}") data = data[index + 1:] if data == '\n': # Returned nothing.. something went wrong data = initial_data jsdata = json.loads(data) # Remove the flac if needed for f in cleanup: command = 'rm -f ' + f if os.system(command): raise RappError("Error: Removal of temporary file malfunctioned") return jsdata
def testTblUserWriteReadDeleteCheck(self): #Write serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_write_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_write_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, writeDataSrv) req = writeDataSrv() req.req_cols = [ "name", "email", "pwd", "activated", "language", "ontology_alias" ] #req.req_cols=["idsd","macddr", "model","owner", "timestamp"] entry1 = StringArrayMsg() entry1 = [ "'rappMysqlTestTemp1'", "'*****@*****.**'", "'rappMysqlTestTemp1TestPass'", "'Y'", "'el'", "NULL" ] entry2 = StringArrayMsg() entry2 = [ "'rappMysqlTestTemp2'", "'*****@*****.**'", "'rappMysqlTestTemp2TestPass'", "'Y'", "'el'", "NULL" ] req.req_data = [StringArrayMsg(s=entry1), StringArrayMsg(s=entry2)] response = db_service(req.req_cols, req.req_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read what was written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_fetch_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["name", "email"] entry1 = ["name", "rappMysqlTestTemp1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "rappMysqlTestTemp1") #self.assertEqual(response.res_data[1].s[0],"*****@*****.**") #Update written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_update_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_update_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, updateDataSrv) req = updateDataSrv() req.set_cols = ["name='rappMysqlTestTemp1'"] entry1 = ["name", "rappMysqlTestTemp2"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.set_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read again serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_read_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["name", "email"] entry1 = ["name", "rappMysqlTestTemp1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "rappMysqlTestTemp1") self.assertEqual(response.res_data[1].s[0], "rappMysqlTestTemp1") #Delete updated serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_delete_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_delete_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, deleteDataSrv) req = deleteDataSrv() entry1 = ["name", "rappMysqlTestTemp1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Check if it was deleted serv_topic = rospy.get_param( 'rapp_mysql_wrapper_user_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_user_read_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["name", "email"] entry1 = ["name", "rappMysqlTestTemp1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertTrue((len(response.res_data) < 1))
def testTblRappWriteReadDeleteCheck(self): #Write serv_topic = rospy.get_param( 'rapp_mysql_wrapper_rapp_write_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_rapp_write_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, writeDataSrv) req = writeDataSrv() req.req_cols = [ "rapp", "version", "arch", "lang", "owner", "directory", "enabled", "timestamp" ] entry1 = StringArrayMsg() entry1 = [ "'testingDB1'", "'1.01'", "'15'", "'1'", "'25'", "'testingDB1'", "'0'", "'555'" ] entry2 = StringArrayMsg() entry2 = [ "'testingDB2'", "'1.01'", "'15'", "'1'", "'25'", "'testingDB1'", "'0'", "'555'" ] req.req_data = [StringArrayMsg(s=entry1), StringArrayMsg(s=entry2)] response = db_service(req.req_cols, req.req_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read what was written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_rapp_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_rapp_fetch_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["rapp", "directory"] entry1 = ["directory", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "testingDB1") self.assertEqual(response.res_data[1].s[0], "testingDB2") #Update written serv_topic = rospy.get_param( 'rapp_mysql_wrapper_rapp_update_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_rapp_update_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, updateDataSrv) req = updateDataSrv() req.set_cols = ["rapp='testingDB3'"] entry1 = ["rapp", "testingDB2"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.set_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Read again serv_topic = rospy.get_param( 'rapp_mysql_wrapper_rapp_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_rapp_read_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["rapp", "directory"] entry1 = ["directory", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertEqual(response.res_data[0].s[0], "testingDB1") self.assertEqual(response.res_data[1].s[0], "testingDB3") #Delete updated serv_topic = rospy.get_param( 'rapp_mysql_wrapper_rapp_delete_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_rapp_delete_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, deleteDataSrv) req = deleteDataSrv() entry1 = ["directory", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) #Check if it was deleted serv_topic = rospy.get_param( 'rapp_mysql_wrapper_rapp_fetch_data_topic') if (not serv_topic): rospy.logerror( "mysql_wrapper_rapp_read_data topic param not found") rospy.wait_for_service(serv_topic) db_service = rospy.ServiceProxy(serv_topic, fetchDataSrv) req = fetchDataSrv() req.req_cols = ["rapp", "directory"] entry1 = ["directory", "testingDB1"] req.where_data = [StringArrayMsg(s=entry1)] response = db_service(req.req_cols, req.where_data) self.assertEqual(response.trace[0], "Success") self.assertTrue(response.success.data) self.assertTrue((len(response.res_data) < 1))