def setUp( self ): """c'tor :param self: self reference """ kwargs = getRegisterRequest() self.registerTask = RegistrationTask( **kwargs ) self.registerTask.dataLoggingClient = Mock( return_value = Mock(spec = DataLoggingClient ) ) self.registerTask.dataLoggingClient().addFileRecord = Mock() self.registerTask.dataLoggingClient().addFileRecord.return_value = { "OK" : True, "Value" : "" } self.registerTask.requestClient = Mock( return_value = Mock(spec=RequestClient) ) self.registerTask.requestClient().updateRequest = Mock() self.registerTask.requestClient().updateRequest.return_value = { "OK" : True, "Value" : None } self.registerTask.requestClient().getRequestStatus = Mock() self.registerTask.requestClient().getRequestStatus.return_value = { "OK" : True, "Value" : { "RequestStatus" : "Done", "SubRequestStatus" : "Done" }} self.registerTask.requestClient().finalizeRequest = Mock() self.registerTask.requestClient().finalizeRequest.return_value = { "OK" : True, "Value" : None } self.registerTask.replicaManager = Mock( return_value = Mock( spec=ReplicaManager) ) self.registerTask.replicaManager().registerFile = Mock() self.registerTask.replicaManager().registerFile.return_value = { "OK" : True, "Value" : { "Failed" : {}, "Succesfull" : { "/lhcb/user/c/cblanks/11889/11889410/LDSB.rsQrRL" : True } } }
class RegisterTaskTests(unittest.TestCase): """ .. class:: RegisterTaskTests """ def setUp(self): """c'tor :param self: self reference """ kwargs = getRegisterRequest() self.registerTask = RegistrationTask(**kwargs) self.registerTask.dataLoggingClient = Mock(return_value=Mock(spec=DataLoggingClient)) self.registerTask.dataLoggingClient().addFileRecord = Mock() self.registerTask.dataLoggingClient().addFileRecord.return_value = {"OK": True, "Value": ""} self.registerTask.requestClient = Mock(return_value=Mock(spec=RequestClient)) self.registerTask.requestClient().updateRequest = Mock() self.registerTask.requestClient().updateRequest.return_value = {"OK": True, "Value": None} self.registerTask.requestClient().getRequestStatus = Mock() self.registerTask.requestClient().getRequestStatus.return_value = { "OK": True, "Value": {"RequestStatus": "Done", "SubRequestStatus": "Done"}, } self.registerTask.requestClient().finalizeRequest = Mock() self.registerTask.requestClient().finalizeRequest.return_value = {"OK": True, "Value": None} self.registerTask.dataManager = Mock(return_value=Mock(spec=DataManager)) self.registerTask.dm.registerFile = Mock() self.registerTask.dm.registerFile.return_value = { "OK": True, "Value": {"Failed": {}, "Succesfull": {"/lhcb/user/c/cblanks/11889/11889410/LDSB.rsQrRL": True}}, } def test_01_call(self): """ call test """ self.assertEqual(self.registerTask.__call__(), {"OK": True, "Value": {"monitor": {"Execute": 1, "Done": 1}}})
class RegisterTaskTests(unittest.TestCase): """ .. class:: RegisterTaskTests """ def setUp( self ): """c'tor :param self: self reference """ kwargs = getRegisterRequest() self.registerTask = RegistrationTask( **kwargs ) self.registerTask.dataLoggingClient = Mock( return_value = Mock(spec = DataLoggingClient ) ) self.registerTask.dataLoggingClient().addFileRecord = Mock() self.registerTask.dataLoggingClient().addFileRecord.return_value = { "OK" : True, "Value" : "" } self.registerTask.requestClient = Mock( return_value = Mock(spec=RequestClient) ) self.registerTask.requestClient().updateRequest = Mock() self.registerTask.requestClient().updateRequest.return_value = { "OK" : True, "Value" : None } self.registerTask.requestClient().getRequestStatus = Mock() self.registerTask.requestClient().getRequestStatus.return_value = { "OK" : True, "Value" : { "RequestStatus" : "Done", "SubRequestStatus" : "Done" }} self.registerTask.requestClient().finalizeRequest = Mock() self.registerTask.requestClient().finalizeRequest.return_value = { "OK" : True, "Value" : None } self.registerTask.replicaManager = Mock( return_value = Mock( spec=ReplicaManager) ) self.registerTask.replicaManager().registerFile = Mock() self.registerTask.replicaManager().registerFile.return_value = { "OK" : True, "Value" : { "Failed" : {}, "Succesfull" : { "/lhcb/user/c/cblanks/11889/11889410/LDSB.rsQrRL" : True } } } def test_01_call( self ): """ call test """ self.assertEqual( self.registerTask.__call__(), { 'OK': True, 'Value': { 'monitor': { 'Execute': 1, 'Done': 1} } } )