def setUp(self): self.channelRPC = ChannelRPC("sqliteMasarTestService") self.channelRPC.issueConnect() if not self.channelRPC.waitConnect(2.0): print "error when waiting connection.", self.channelRPC.getMessage( ) # AttributeError: 'module' object has no attribute '_getMessage' raise AttributeError(self.channelRPC.getMessage())
def setUp(self): self.channelRPC = ChannelRPC("sqliteMasarTestService") self.channelRPC.issueConnect() if not self.channelRPC.waitConnect(2.0): print "error when waiting connection.", self.channelRPC.getMessage() # AttributeError: 'module' object has no attribute '_getMessage' raise AttributeError(self.channelRPC.getMessage())
def __clientRPC(function, params): alarm = Alarm() timeStamp = TimeStamp() ntnv = NTNameValue(function, params) # now do issue + wait channelRPC = ChannelRPC("masarService") channelRPC.issueConnect() if not channelRPC.waitConnect(1.0): print "error when waiting connection.", channelRPC.getMessage() exit(1) channelRPC.issueRequest(ntnv.getNTNameValue(), False) result = channelRPC.waitResponse() if result is None: print channelRPC.getMessage() exit(1) # print "problem to get nttable using getNTTable()" if function in ["retrieveSnapshot", "getLiveMachine", "saveSnapshot"]: result = NTMultiChannel(result) elif function in ["retrieveServiceEvents", "retrieveServiceConfigs", "retrieveServiceConfigProps"]: result = NTTable(result) label = result.getLabels() print "label", label print result.getPVStructure() elif function == "updateSnapshotEvent": result = NTScalar(result) # print "Problem above" # print result result.getAlarm(alarm) # print alarm result.getTimeStamp(timeStamp) # print timeStamp # numberValues = result.getNumberValues() # print "numberValues", numberValues # # i = 0 # while i < numberValues : # value = nttable.getValue(i) # print "value",label[i],value # i += 1 return result
class TestChannelRPC(unittest.TestCase): ''' Tests initial connection to channelRPC and establishes connections for each test ''' def setUp(self): self.channelRPC = ChannelRPC("sqliteMasarTestService") self.channelRPC.issueConnect() if not self.channelRPC.waitConnect(2.0): print "error when waiting connection.", self.channelRPC.getMessage( ) # AttributeError: 'module' object has no attribute '_getMessage' raise AttributeError(self.channelRPC.getMessage()) ''' Tests retrieveSnapshot function, makes assertion for successful request and for correct results ''' def testRetrieveSnapshot(self): function = "retrieveSnapshot" params = {'eventid': '365'} self.ntnv_asserts(function, params) ''' Tests saveSnapshot function, makes assertion for successful request and for correct results ''' def testSaveSnapshot(self): function = "saveSnapshot" params = {'configname': 'wf_test', 'servicename': 'masar'} self.ntnv_asserts(function, params) def ntnv_asserts(self, function, params): alarm = Alarm() time_stamp = TimeStamp() ntnv = NTNameValue(function, params) self.channelRPC.issueRequest(ntnv.getNTNameValue(), False) response = self.channelRPC.waitResponse() self.assertNotEqual(response, None, "ChannelRPC connection failure.") result = NTMultiChannel(response) result.getAlarm(alarm) result.getTimeStamp(time_stamp) self.assertEqual(3, len( str(time_stamp).split(":"))) # Timestamp string format test self.assertIn(alarm.getStatus(), alarm.getStatusChoices()) self.assertIn(alarm.getSeverity(), alarm.getSeverityChoices()) ''' Tests retrieveServiceEvents function, makes assertion for successful request and for correct results ''' def testRetrieveServiceEvents(self): function = "retrieveServiceEvents" params = {'configid': '1'} self.nttable_asserts(function, params) ''' Tests retrieveServiceConfigProps function, makes assertion for successful request and for correct results ''' def testRetrieveServiceConfigProps(self): function = "retrieveServiceConfigProps" params = {'propname': 'system', 'configname': 'SR_All_SCR_20140421'} self.nttable_asserts(function, params) ''' Tests retrieveServiceConfigs function, makes assertion for successful request and for correct results ''' def testRetrieveServiceConfigs(self): function = "retrieveServiceConfigs" params = {'system': 'all'} self.nttable_asserts(function, params) def nttable_asserts(self, function, params): alarm = Alarm() time_stamp = TimeStamp() ntnv = NTNameValue(function, params) self.channelRPC.issueRequest(ntnv.getNTNameValue(), False) response = self.channelRPC.waitResponse() self.assertNotEqual(response, None, "ChannelRPC connection failure.") result = NTTable(response) label = result.getLabels() self.assertNotEqual(label, None) result.getAlarm(alarm) result.getTimeStamp(time_stamp) self.assertEqual(3, len( str(time_stamp).split(":"))) # Timestamp string format test self.assertIn(alarm.getStatus(), alarm.getStatusChoices()) self.assertIn(alarm.getSeverity(), alarm.getSeverityChoices()) if __name__ == '__main__': unittest.main()
class TestChannelRPC(unittest.TestCase): ''' Tests initial connection to channelRPC and establishes connections for each test ''' def setUp(self): self.channelRPC = ChannelRPC("sqliteMasarTestService") self.channelRPC.issueConnect() if not self.channelRPC.waitConnect(2.0): print "error when waiting connection.", self.channelRPC.getMessage() # AttributeError: 'module' object has no attribute '_getMessage' raise AttributeError(self.channelRPC.getMessage()) ''' Tests retrieveSnapshot function, makes assertion for successful request and for correct results ''' def testRetrieveSnapshot(self): function = "retrieveSnapshot" params = {'eventid': '365'} self.ntnv_asserts(function,params) ''' Tests saveSnapshot function, makes assertion for successful request and for correct results ''' def testSaveSnapshot(self): function = "saveSnapshot" params = {'configname': 'wf_test', 'servicename': 'masar'} self.ntnv_asserts(function, params) def ntnv_asserts(self, function, params): alarm = Alarm() time_stamp = TimeStamp() ntnv = NTNameValue(function, params) self.channelRPC.issueRequest(ntnv.getNTNameValue(), False) response = self.channelRPC.waitResponse() self.assertNotEqual(response, None, "ChannelRPC connection failure.") result = NTMultiChannel(response) result.getAlarm(alarm) result.getTimeStamp(time_stamp) self.assertEqual(3, len(str(time_stamp).split(":"))) # Timestamp string format test self.assertIn(alarm.getStatus(), alarm.getStatusChoices()) self.assertIn(alarm.getSeverity(), alarm.getSeverityChoices()) ''' Tests retrieveServiceEvents function, makes assertion for successful request and for correct results ''' def testRetrieveServiceEvents(self): function = "retrieveServiceEvents" params = {'configid': '1'} self.nttable_asserts(function, params) ''' Tests retrieveServiceConfigProps function, makes assertion for successful request and for correct results ''' def testRetrieveServiceConfigProps(self): function = "retrieveServiceConfigProps" params = {'propname': 'system', 'configname': 'SR_All_SCR_20140421'} self.nttable_asserts(function, params) ''' Tests retrieveServiceConfigs function, makes assertion for successful request and for correct results ''' def testRetrieveServiceConfigs(self): function = "retrieveServiceConfigs" params = {'system': 'all'} self.nttable_asserts(function, params) def nttable_asserts(self, function, params): alarm = Alarm() time_stamp = TimeStamp() ntnv = NTNameValue(function, params) self.channelRPC.issueRequest(ntnv.getNTNameValue(), False) response = self.channelRPC.waitResponse() self.assertNotEqual(response, None, "ChannelRPC connection failure.") result = NTTable(response) label = result.getLabels() self.assertNotEqual(label, None) result.getAlarm(alarm) result.getTimeStamp(time_stamp) self.assertEqual(3, len(str(time_stamp).split(":"))) # Timestamp string format test self.assertIn(alarm.getStatus(), alarm.getStatusChoices()) self.assertIn(alarm.getSeverity(), alarm.getSeverityChoices()) if __name__ == '__main__': unittest.main()
def __clientRPC(function, params): alarm = Alarm() timeStamp = TimeStamp() ntnv = NTNameValue(function,params) # now do issue + wait channelRPC = ChannelRPC("masarService","record[process=true]field()") channelRPC.issueConnect() if not channelRPC.waitConnect(1.0) : print channelRPC.getMessage() exit(1) channelRPC.issueRequest(ntnv.getNTNameValue(),False) result = channelRPC.waitRequest() if(result==None) : print channelRPC.getMessage() exit(1) nttable = NTTable(result) print nttable nttable.getAlarm(alarm.getAlarmPy()) # print alarm; nttable.getTimeStamp(timeStamp.getTimeStampPy()) # print timeStamp; # numberValues = nttable.getNumberValues() # print "numberValues",numberValues # # label = nttable.getLabel() # print "label",label # # i = 0 # while i < numberValues : # value = nttable.getValue(i) # print "value",label[i],value # i += 1 return nttable
def __clientRPC(function, params): alarm = Alarm() timeStamp = TimeStamp() ntnv = NTNameValue(function, params) # now do issue + wait channelRPC = ChannelRPC("masarService") channelRPC.issueConnect() if not channelRPC.waitConnect(1.0): print "error when waiting connection.", channelRPC.getMessage() exit(1) channelRPC.issueRequest(ntnv.getNTNameValue(), False) result = channelRPC.waitResponse() if result is None: print channelRPC.getMessage() exit(1) # print "problem to get nttable using getNTTable()" if function in ["retrieveSnapshot", "getLiveMachine", "saveSnapshot"]: result = NTMultiChannel(result) elif function in [ "retrieveServiceEvents", "retrieveServiceConfigs", "retrieveServiceConfigProps" ]: result = NTTable(result) label = result.getLabels() print "label", label print result.getPVStructure() elif function == "updateSnapshotEvent": result = NTScalar(result) # print "Problem above" # print result result.getAlarm(alarm) # print alarm result.getTimeStamp(timeStamp) # print timeStamp # numberValues = result.getNumberValues() # print "numberValues", numberValues # # i = 0 # while i < numberValues : # value = nttable.getValue(i) # print "value",label[i],value # i += 1 return result