コード例 #1
0
 def testGetNumInstances_CurrentModule(self):
     self.request_data.get_dispatcher().AndReturn(self.dispatcher)
     self.request_data.get_module(None).AndReturn('default')
     self.dispatcher.get_num_instances('default', '1').AndReturn(5)
     self.mox.ReplayAll()
     self.assertEqual(5, modules.get_num_instances(version='1'))
     self.mox.VerifyAll()
コード例 #2
0
 def testGetNumInstances_CurrentVersionDifferentModule(self):
     self.request_data.get_dispatcher().AndReturn(self.dispatcher)
     self.request_data.get_version(None).AndReturn('1')
     self.dispatcher.get_versions('other').AndReturn(['1'])
     self.dispatcher.get_num_instances('other', '1').AndReturn(5)
     self.mox.ReplayAll()
     self.assertEqual(5, modules.get_num_instances(module='other'))
     self.mox.VerifyAll()
コード例 #3
0
 def testGetNumInstances_AllDefaults(self):
   """Test we return the expected results when no args are passed."""
   expected_request = modules_service_pb2.GetNumInstancesRequest()
   service_response = modules_service_pb2.GetNumInstancesResponse()
   service_response.instances = 11
   self.SetSuccessExpectations('GetNumInstances',
                               expected_request,
                               service_response)
   self.assertEqual(11, modules.get_num_instances())
コード例 #4
0
 def testGetNumInstances_NoModule(self):
   """Test we return the expected results when no module is passed."""
   expected_request = modules_service_pb2.GetNumInstancesRequest()
   expected_request.version = 'v1'
   service_response = modules_service_pb2.GetNumInstancesResponse()
   service_response.instances = 11
   self.SetSuccessExpectations('GetNumInstances',
                               expected_request,
                               service_response)
   self.assertEqual(11, modules.get_num_instances(version='v1'))