Ejemplo n.º 1
0
 def create_model(self, *args):
     """
     create an instance of the model being tested, this will instrument
     some methods of the model to check if they have been called
     """
     object = self.Model(*args)
     
     # patch model class
     CallProxy.patch(object, 'parse_transient_info')
     CallProxy.patch(object, 'parse_persistent_info')
     CallProxy.patch(object, '_refresh')
     CallProxy.patch(object, 'load_info')
     CallProxy.patch(object, 'save')
     return object
Ejemplo n.º 2
0
 def create_model(self, **kwargs):
     """
     create an instance of the model being tested, this will instrument
     some methods of the model to check if they have been called
     """
     cluster, chaff = Cluster.objects.get_or_create(hostname='test.foo.org')
     object = self.Model(cluster=cluster, **kwargs)
     
     # patch model class
     CallProxy.patch(object, 'parse_transient_info')
     CallProxy.patch(object, 'parse_persistent_info')
     CallProxy.patch(object, '_refresh')
     CallProxy.patch(object, 'load_info')
     CallProxy.patch(object, 'save')
     return object
Ejemplo n.º 3
0
Archivo: job.py Proyecto: bsu/GWM
 def test_cache_reset_error(self):
     """
     Tests that cache reset is working properly.
     
     Verifies:
         * when success or error status is achieved the job no longer updates
     """
     job = self.test_save()
     job.ignore_cache = True
     job.save()
     rapi = job.rapi
     rapi.GetJobStatus.response = JOB_RUNNING
     CallProxy.patch(job, '_refresh')
     
     # load with running status, should refresh
     job.load_info()
     self.assert_(job.ignore_cache)
     job._refresh.assertCalled(self)
     job._refresh.reset()
     
     # load again with running status, should refresh
     job.load_info()
     self.assert_(job.ignore_cache)
     job._refresh.assertCalled(self)
     job._refresh.reset()
     
     # load again with success status, should refresh and flip cache flag
     rapi.GetJobStatus.response = JOB_ERROR
     job.load_info()
     self.assertFalse(job.ignore_cache)
     job._refresh.assertCalled(self)
     job._refresh.reset()
     
     # load again with success status, should use cache
     job.load_info()
     self.assertFalse(job.ignore_cache)
     job._refresh.assertNotCalled(self)
Ejemplo n.º 4
0
    def __new__(klass, *args, **kwargs):
        instance = object.__new__(klass)
        instance.__init__(*args, **kwargs)
        CallProxy.patch(instance, 'GetInstances', False, INSTANCES)
        CallProxy.patch(instance, 'GetInstance', False, INSTANCE)
        CallProxy.patch(instance, 'GetNodes', False, NODES_MAP)
        CallProxy.patch(instance, 'GetNode', False, NODE)
        CallProxy.patch(instance, 'GetInfo', False, INFO)
        CallProxy.patch(instance, 'GetOperatingSystems', False, OPERATING_SYSTEMS)
        CallProxy.patch(instance, 'GetJobStatus', False, JOB_RUNNING)
        CallProxy.patch(instance, 'StartupInstance', False, 1)
        CallProxy.patch(instance, 'ShutdownInstance', False, 1)
        CallProxy.patch(instance, 'RebootInstance', False, 1)
        CallProxy.patch(instance, 'ReinstallInstance', False, 1)
        CallProxy.patch(instance, 'AddInstanceTags', False)
        CallProxy.patch(instance, 'DeleteInstanceTags', False)
        CallProxy.patch(instance, 'CreateInstance', False, 1)
        CallProxy.patch(instance, 'DeleteInstance', False, 1)
        CallProxy.patch(instance, 'ModifyInstance', False, 1)
        CallProxy.patch(instance, 'MigrateInstance', False, 1)
        CallProxy.patch(instance, 'RenameInstance', False, 1)

        CallProxy.patch(instance, 'SetNodeRole', False, 1)
        CallProxy.patch(instance, 'EvacuateNode', False, 1)
        CallProxy.patch(instance, 'MigrateNode', False, 1)
        
        return instance