def setUp(self): # remote.RemoteTestResult.__init__() Stream = flexmock() (flexmock(os).should_receive('getcwd').and_return( '/current/directory').once().ordered()) # vm.VMTestResult.setup() (Stream.should_receive('notify').with_args(msg="DOMAIN : domain", event="message")) mock_vm = flexmock(snapshot=True, domain=flexmock(isActive=lambda: True)) flexmock(virt).should_receive('vm_connect').and_return( mock_vm).once().ordered() mock_vm.should_receive('start').and_return(True).once().ordered() mock_vm.should_receive('create_snapshot').once().ordered() flexmock(RemoteTestResult).should_receive('setup').once().ordered() # vm.RemoteTestResult() Args = flexmock( test_result_total=1, url=['/tests/sleeptest', '/tests/other/test', 'passtest'], vm_domain='domain', vm_username='******', vm_hostname='hostname', vm_port=22, vm_password='******', vm_cleanup=True, vm_no_copy=False, vm_timeout=120, vm_hypervisor_uri='my_hypervisor_uri') self.remote = VMTestResult(Stream, Args) # vm.RemoteTestResult.tear_down() RemoteTestResult.should_receive('tear_down').once().ordered() mock_vm.should_receive('stop').once().ordered() mock_vm.should_receive('restore_snapshot').once().ordered()
def setUp(self): # remote.RemoteTestResult.__init__() Stream = flexmock() (flexmock(os).should_receive('getcwd') .and_return('/current/directory').once().ordered()) # vm.VMTestResult.setup() (Stream.should_receive('notify') .with_args(msg="DOMAIN : domain", event="message")) mock_vm = flexmock(snapshot=True, domain=flexmock(isActive=lambda: True)) flexmock(virt).should_receive('vm_connect').and_return(mock_vm).once().ordered() mock_vm.should_receive('start').and_return(True).once().ordered() mock_vm.should_receive('create_snapshot').once().ordered() flexmock(RemoteTestResult).should_receive('setup').once().ordered() # vm.RemoteTestResult() Args = flexmock(test_result_total=1, url=['/tests/sleeptest', '/tests/other/test', 'passtest'], vm_domain='domain', vm_username='******', vm_hostname='hostname', vm_port=22, vm_password='******', vm_cleanup=True, vm_no_copy=False, vm_hypervisor_uri='my_hypervisor_uri') self.remote = VMTestResult(Stream, Args) # vm.RemoteTestResult.tear_down() RemoteTestResult.should_receive('tear_down').once().ordered() mock_vm.should_receive('restore_snapshot').once().ordered()
def __init__(self, job): """ Creates an instance of RemoteTestResult. :param job: an instance of :class:`avocado.core.job.Job`. """ RemoteTestResult.__init__(self, job) self.test_dir = os.getcwd() self.remote_test_dir = '~/avocado/tests' self.urls = self.args.url self.remote = None # Remote runner initialized during setup self.output = '-'