def testOrderPersistsOverReload(self): # Setup self.setUpMVMock() run_vm_name = "TEST-VM-RUN" stop_vm_name = "TEST-VM-STOP" self.addRunningVMs(run_vm_name, 1) self.addStoppedVMs(stop_vm_name, 0) mox.Replay(self.virConnectMock, self.virDomainMock) #Test vm_catalog = VMCatalog() assert isinstance(vm_catalog, VMCatalog) vm_catalog.refesh() vm = vm_catalog.get_vm(run_vm_name + "-0") assert isinstance(vm, VMInstance) order = 1 vm.set_order(1) #Setup mox.Reset(self.virConnectMock, self.virDomainMock) self.addRunningVMs(run_vm_name, 1) self.addStoppedVMs(stop_vm_name, 0) mox.Replay(self.virConnectMock, self.virDomainMock) vm_catalog.refesh() vm = vm_catalog.get_vm(run_vm_name + "-0") #Assert self.assertEqual(order, vm.get_order())
def testSettings(self): ac = launcher.AppController(self.app) failures = [0] def failure_accum(a, b): failures[0] += 1 ac._FailureMessage = failure_accum # First make sure we choke if !=1 project is selected for projectlist in ((), (1, 2, 4)): failures = [0] frame_mock = mox.MockObject(launcher.MainFrame) frame_mock.SelectedProjects().AndReturn(projectlist) mox.Replay(frame_mock) ac.SetModelsViews(frame=frame_mock) ac.Settings(self, None) mox.Verify(frame_mock) self.assertEqual(1, failures[0]) # Now test things look fine with 1 project. frame_mock = mox.MockObject(launcher.MainFrame) frame_mock.SelectedProjects().AndReturn((1, )) frame_mock.RefreshView(None) mox.Replay(frame_mock) table_mock = mox.MockObject(launcher.MainTable) table_mock.SaveProjects() table_mock._projects = None mox.Replay(table_mock) ac.SetModelsViews(frame=frame_mock, table=table_mock) controller_mock = mox.MockObject(launcher.SettingsController) controller_mock.ShowModal().AndReturn(wx.ID_OK) mox.Replay(controller_mock) ac.Settings(None, settings_controller=controller_mock) mox.Verify(frame_mock) mox.Verify(table_mock) mox.Verify(controller_mock)
def testRemove(self): """Test Remove with both single and multiple projects.""" # Simulate with both positive and negative responses. # These functions will replace launcher.Controller_ConfirmRemove(). confirm_functions = (lambda a, b: True, lambda a, b: False) for confirm_function in confirm_functions: plists = (self.Projects(1), self.Projects(4)) for projectlist in plists: frame_mock = mox.MockObject(launcher.MainFrame) frame_mock.SelectedProjects().AndReturn(projectlist) table_mock = mox.MockObject(launcher.MainTable) table_mock._projects = None # Only if _ConfirmRemove() will return True do we tell our # mock to expect deletes to happen (RemoveProject() calls). if confirm_function(0, 0): for p in projectlist: table_mock.RemoveProject(p).InAnyOrder() frame_mock.UnselectAll() frame_mock.RefreshView(None) mox.Replay(frame_mock) mox.Replay(table_mock) controller = launcher.AppController(self.app) controller._ConfirmRemove = confirm_function controller.SetModelsViews(frame=frame_mock, table=table_mock) controller.Remove(None) mox.Verify(frame_mock)
def testGetMixedVmInstancesHistoryChange(self): # Setup self.setUpMVMock() run_vm_name = "TEST-VM-RUN" stop_vm_name = "TEST-VM-STOP" self.addRunningVMs(run_vm_name, 1) self.addStoppedVMs(stop_vm_name, 1) mox.Replay(self.virConnectMock, self.virDomainMock) #Test vm_catalog = VMCatalog() history_changed = vm_catalog.refesh() #Assert self.assertEqual(True, history_changed) #Setup mox.Reset(self.virConnectMock, self.virDomainMock) self.addRunningVMs(run_vm_name, 0) self.addStoppedVMs(stop_vm_name, 2) mox.Replay(self.virConnectMock, self.virDomainMock) #Test history_changed = vm_catalog.refesh() #Assert self.assertEqual(True, history_changed)
def testFail(self): #first try to make a non existant file (regular) self.runMocker.runCommand( [self.commandPrepend,'dccp', '-o', '86400', '-d', '0', '-X', '-role=cmsprod', '/store/NONEXISTANTSOURCE', '/store/NONEXISTANTTARGET' ]\ ).AndReturn(("1", "This was a test of the fail system")) #then try to make a non existant file on lustre # -- fake making a directory self.runMocker.runCommand( [self.commandPrepend, 'mkdir', '-m', '755', '-p', '/store/unmerged']\ ).AndReturn(("0", "we made a directory, yay")) # -- fake the actual copy self.copyMocker.doTransfer( \ '/store/unmerged/lustre/NONEXISTANTSOURCE', '/store/unmerged/lustre/NONEXISTANTTARGET', True, None, None, None, None\ ).AndRaise(StageOutFailure("testFailure")) # do one with a real pfn self.runMocker.runCommand(\ [self.commandPrepend, 'mkdir', '-m', '755', '-p',\ '/pnfs/cms/WAX/11/store/temp/WMAgent/unmerged/RECO/WMAgentCommissioning10-v7newstageout']).AndReturn(("0","")) self.runMocker.runCommand([ self.commandPrepend, 'dccp', '-o', '86400', '-d', '0', '-X', '-role=cmsprod', 'file:///etc/hosts', 'dcap://cmsdca.fnal.gov:24037/pnfs/fnal.gov/usr/cms/WAX/11/store/temp/WMAgent/unmerged/RECO/WMAgentCommissioning10-v7newstageout/0000/0661D749-DD95-DF11-8A0F-00261894387C.root ' ]).AndReturn(("0", "")) # now try to delete it (pnfs) self.runMocker.runCommand( ['rm', '-fv', '/pnfs/cms/WAX/11/store/tmp/testfile' ]\ ).AndReturn(("1", "This was a test of the fail system")) # try to delete it (lustre) self.runMocker.runCommand( ['/bin/rm', '/lustre/unmerged/NOTAFILE']\ ).AndReturn(("1", "This was a test of the fail system")) mox.Replay(self.runMocker) mox.Replay(self.copyMocker) #ourPlugin.runCommand = runMocker.runCommand() testObject = ourPlugin() self.assertRaises(StageOutFailure, testObject.doTransfer, '/store/NONEXISTANTSOURCE', '/store/NONEXISTANTTARGET', True, None, None, None, None) self.assertRaises(StageOutFailure, testObject.doTransfer, '/store/unmerged/lustre/NONEXISTANTSOURCE', '/store/unmerged/lustre/NONEXISTANTTARGET', True, None, None, None, None) self.assertRaises( StageOutFailure, testObject.doTransfer, 'file:///etc/hosts', 'dcap://cmsdca.fnal.gov:24037/pnfs/fnal.gov/usr/cms/WAX/11/store/temp/WMAgent/unmerged/RECO/WMAgentCommissioning10-v7newstageout/0000/0661D749-DD95-DF11-8A0F-00261894387C.root ', True, None, None, None, None) testObject.doDelete('/store/tmp/testfile', None, None, None, None) testObject.doDelete('/store/unmerged/lustre/NOTAFILE', None, None, None, None) mox.Verify(self.runMocker) mox.Verify(self.copyMocker)
def testWin(self): #first try to make a file (regular). this one works self.runMocker.runCommand( [self.commandPrepend,'dccp', '-o', '86400', '-d', '0', '-X', '-role=cmsprod', '/store/NONEXISTANTSOURCE', '/store/NONEXISTANTTARGET' ]\ ).AndReturn((0, "This transfer works")) self.runMocker.runCommand( [self.commandPrepend,'/opt/d-cache/dcap/bin/check_dCachefilecksum.sh', '/store/NONEXISTANTTARGET', '/store/NONEXISTANTSOURCE']\ ).AndReturn((0, "Oh, the checksum was checked")) # now make a file and have the checksum fail self.runMocker.runCommand( [self.commandPrepend,'dccp', '-o', '86400', '-d', '0', '-X', '-role=cmsprod', '/store/NONEXISTANTSOURCE', '/store/NONEXISTANTTARGET' ]\ ).AndReturn((0, "This transfer works")) self.runMocker.runCommand( [self.commandPrepend,'/opt/d-cache/dcap/bin/check_dCachefilecksum.sh', '/store/NONEXISTANTTARGET', '/store/NONEXISTANTSOURCE']\ ).AndReturn((1, "Oh, the checksum was checked. Things look bad")) self.runMocker.runCommand( [self.commandPrepend, 'mkdir', '-m', '755', '-p', '/store/unmerged']\ ).AndReturn((0, "")) #then try to make a non existant file on lustre # -- fake making a directory self.runMocker.runCommand( [self.commandPrepend, 'mkdir', '-m', '755', '-p', '/store/unmerged']\ ).AndReturn((0, "we made a directory, yay")) # -- fake the actual copy self.copyMocker.doTransfer( \ '/store/unmerged/lustre/NONEXISTANTSOURCE', '/store/unmerged/lustre/NONEXISTANTTARGET', True, None, None, None, None\ ).AndReturn("balls") mox.Replay(self.runMocker) mox.Replay(self.copyMocker) #ourPlugin.runCommand = runMocker.runCommand() testObject = ourPlugin() # copy normally and have it work newPfn = testObject.doTransfer('/store/NONEXISTANTSOURCE', '/store/NONEXISTANTTARGET', True, None, None, None, None) self.assertEqual(newPfn, '/store/NONEXISTANTTARGET') # second time fails the checksum self.assertRaises(StageOutFailure, testObject.doTransfer, '/store/NONEXISTANTSOURCE', '/store/NONEXISTANTTARGET', True, None, None, None, None) # copy to lustre normally and have it work newPfn = testObject.doTransfer( '/store/unmerged/lustre/NONEXISTANTSOURCE', '/store/unmerged/lustre/NONEXISTANTTARGET', True, None, None, None, None) self.assertEqual(newPfn, "balls") mox.Verify(self.runMocker) mox.Verify(self.copyMocker)
def test_sendall(self): self.ais.sock = mox.MockAnything() self.m.StubOutWithMock(self.ais, "close") # part 1 not connected # # part 2 socket.error self.ais.sock.setblocking(mox.IgnoreArg()) self.ais.sock.settimeout(mox.IgnoreArg()) self.ais.sock.sendall(mox.IgnoreArg()).AndRaise(socket.error) self.ais.close() # part 3 empty input # mox.Replay(self.ais.sock) self.m.ReplayAll() # part 1 self.ais._connected = False with self.assertRaises(aprslib.ConnectionError): self.ais.sendall("test") # part 2 self.ais._connected = True with self.assertRaises(aprslib.ConnectionError): self.ais.sendall("test") # part 3 self.ais._connected = True self.ais.sendall("") # verify so far mox.Verify(self.ais.sock) self.m.VerifyAll() # rest self.ais._connected = True for line in [ "test", # no \r\n "test\r\n", # with \r\n u"test", # unicode 5, # number or anything with __str__ ]: # setup self.ais.sock = mox.MockAnything() self.ais.sock.setblocking(mox.IgnoreArg()) self.ais.sock.settimeout(mox.IgnoreArg()) self.ais.sock.sendall("%s\r\n" % str(line).rstrip('\r\n')).AndReturn(None) mox.Replay(self.ais.sock) self.ais.sendall(line) mox.Verify(self.ais.sock)
def testDeploy(self): projects = self.Projects(5) tc = launcher.TaskController(FakeAppController()) frame_mock = mox.MockObject(launcher.MainFrame) frame_mock.SelectedProjects().MultipleTimes().AndReturn(projects) mox.Replay(frame_mock) deploy_controller = mox.MockObject(launcher.DeployController) deploy_controller.InitiateDeployment() mox.Replay(deploy_controller) tc.SetModelsViews(frame=frame_mock) tc.Deploy(None, deploy_controller) mox.Verify(deploy_controller) mox.Verify(frame_mock)
def testShowModal(self): project = launcher.Project('path', 9000) for (wx_rtn, updated_calls) in ((wx.ID_OK, 1), (wx.ID_CANCEL, 0)): sc = launcher.SettingsController(project) settings_dialog = project_dialogs.ProjectSettingsDialog dialog_mock = mox.MockObject(settings_dialog) dialog_mock.ShowModal().AndReturn(wx_rtn) mox.Replay(dialog_mock) sc.dialog = dialog_mock actual_updated = [0] def plusone(): """Must use mutable to modify var in enclosing scope.""" actual_updated[0] += 1 sc._UpdateProject = plusone rtn = sc.ShowModal() self.assertEqual(wx_rtn, rtn) mox.Verify(dialog_mock) self.assertEqual(updated_calls, actual_updated[0]) # SettingsController needs to Destroy() its dialog. # That is done in SettingsController's __del__. # But that's past the mox.Verify(), so we can't expect it. # We can, however, make sure it doesn't cause mox # to yell. sc.dialog = None
def testArchiveIsValid(self): """Test the DirectoryZipper.ArchiveIsValid method. Run two tests, one that we expect to pass and one that we expect to fail """ test_file_size = 1056730 self.my_mox.StubOutWithMock(os, 'stat') os.stat('/foo/0.zip').AndReturn([test_file_size]) self.my_mox.StubOutWithMock(stat, 'ST_SIZE') stat.ST_SIZE = 0 os.stat('/baz/0.zip').AndReturn([test_file_size]) mox.Replay(os.stat) test_target = divide_and_compress.DirectoryZipper( '/foo/', 'bar', test_file_size - 1, True) self.assertEqual(False, test_target.ArchiveIsValid(), msg=('ERROR: Test failed, ArchiveIsValid should have ' 'returned false, but returned true')) test_target = divide_and_compress.DirectoryZipper( '/baz/', 'bar', test_file_size + 1, True) self.assertEqual(True, test_target.ArchiveIsValid(), msg=('ERROR: Test failed, ArchiveIsValid should have' ' returned true, but returned false'))
def test_leave(self): real_typepad_client = typepad.client typepad.client = mox.MockObject(httplib2.Http) try: resp = httplib2.Response({ 'status': 200, 'etag': '7', 'content-type': 'application/json', 'content-location': 'http://127.0.0.1:8000/relationships/6r00d83451ce6b69e20120a81fb3a4970c/status.json', }) typepad.client.request( uri='http://127.0.0.1:8000/relationships/6r00d83451ce6b69e20120a81fb3a4970c/status.json', headers={'accept': 'application/json'}, ).AndReturn((resp, """{"types": ["tag:api.typepad.com,2009:Member"]}""")) resp = httplib2.Response({ 'status': 200, 'etag': '9', 'content-type': 'application/json', 'content-location': 'http://127.0.0.1:8000/relationships/6r00d83451ce6b69e20120a81fb3a4970c/status.json', }) typepad.client.request( uri='http://127.0.0.1:8000/relationships/6r00d83451ce6b69e20120a81fb3a4970c/status.json', method='PUT', headers={'if-match': '7', 'accept': 'application/json', 'content-type': 'application/json'}, body=mox.Func(json_equals_func({"types": []})), ).AndReturn((resp, """{"types": []}""")) mox.Replay(typepad.client) r = typepad.Relationship.get('http://127.0.0.1:8000/relationships/6r00d83451ce6b69e20120a81fb3a4970c.json') r.leave() mox.Verify(typepad.client) finally: typepad.client = real_typepad_client
def testRemoveListener(self): """Test that listeners are not called when they have been unregistered.""" self.getField().setPropertyDataSource(ObjectProperty('')) self.getField().setWriteThrough(True) self.getField().setReadThrough(True) # Expectations and start test self._listener.valueChange(mox.IsA(ValueChangeEvent)) mox.Replay(self._listener) # Add listener and set the value -> should end up in listener once self.getField().addListener(self._listener, IValueChangeListener) self.setValue(self.getField()) # Ensure listener was called once mox.Verify(self._listener) # Remove the listener and set the value -> should not end up in # listener self.getField().removeListener(self._listener, IValueChangeListener) self.setValue(self.getField()) # Ensure listener still has been called only once mox.Verify(self._listener)
def testOnPreferences(self): ac = launcher.AppController(self.app) pref_controller_mock = mox.MockObject(launcher.PrefController) pref_controller_mock.ShowModal() mox.Replay(pref_controller_mock) ac.OnPreferences(None, pref_controller_mock) mox.Verify(pref_controller_mock)
def test_slice_filter(self): class Toybox(self.cls): pass h = mox.MockObject(httplib2.Http) mox.Replay(h) b = Toybox.get('http://example.com/foo', http=h) self.assertEquals(b._location, 'http://example.com/foo') j = b[0:10] self.assert_(isinstance(j, Toybox)) self.assertEquals(j._location, 'http://example.com/foo?limit=10&offset=0') j = b[300:370] self.assert_(isinstance(j, Toybox)) self.assertEquals(j._location, 'http://example.com/foo?limit=70&offset=300') j = b[1:] self.assert_(isinstance(j, Toybox)) self.assertEquals(j._location, 'http://example.com/foo?offset=1') j = b[:10] self.assert_(isinstance(j, Toybox)) self.assertEquals(j._location, 'http://example.com/foo?limit=10') # Nobody did any HTTP, right? mox.Verify(h)
def testValueChangeEventPropagationWithReadThrough(self): """Test that field propagates value change events originating from property, but don't fire value change events twice if value has only changed once. TODO: make test field type agnostic (eg. combobox) """ prop = ObjectProperty('') self.getField().setPropertyDataSource(prop) # defaults, buffering off self.getField().setWriteThrough(True) self.getField().setReadThrough(True) # Expectations and start test self.getListener().valueChange(mox.IsA(ValueChangeEvent)) mox.Replay(self.getListener()) # Add listener and set the value -> should end up in listener once self.getField().addListener(self.getListener(), IValueChangeListener) prop.setValue('Foo') # Ensure listener was called once mox.Verify(self.getListener()) # get value should not fire value change again value = self.getField().getValue() self.assertEquals('Foo', value) # Ensure listener still has been called only once mox.Verify(self.getListener())
def testGetMixedVmInstancesOrderAttached(self): self.setUpMVMock() # Setup running instance self.virConnectMock.listDomainsID().AndReturn([1]) run_vm_name = "TEST-VM-RUN" self.virDomainMock.name().AndReturn(run_vm_name) self.virConnectMock.lookupByID(1).AndReturn(self.virDomainMock) # Setup stopped instance stop_vm_name = "TEST-VM-STOP" self.virConnectMock.listDefinedDomains().AndReturn([stop_vm_name]) mox.Replay(self.virConnectMock, self.virDomainMock) vm_catalog = VMCatalog() vm_catalog.refesh() vm_catalog.get_vm(run_vm_name).set_order(1) vms = vm_catalog.get_vms() self.assertEqual(2, len(vms), "There should be two vms! / "\ + str(len(vms))) self.assertEqual(stop_vm_name, vms[1].get_name(), \ "VM name does not match! / " \ + stop_vm_name + vms[1].get_name()) self.assertEqual(c.STATE_STOPPED, vms[1].get_state().get_state_str(), \ "VM should be stopped / " + vms[1].get_state().get_state_str()) self.assertEqual(run_vm_name, vms[0].get_name(), \ "VM name does not match! / " + vms[0].get_name()) self.assertEqual(c.STATE_RUNNING, vms[0].get_state().get_state_str(), \ "VM should be running / " + vms[0].get_state().get_state_str()) self.assertEqual(1, vms[0].get_order(), \ "VM should have order / " + str(vms[0].get_order()))
def testOk(self): mock_passphrase = 'random keychain passphrase' mock_full_keychain = self.mox.CreateMockAnything() mock_full_keychain_file = self.mox.CreateMockAnything() mock_pub_keychain = self.mox.CreateMockAnything() mock_pub_keychain_file = self.mox.CreateMockAnything() open_ = self.mox.CreateMockAnything() self.mox.StubOutWithMock(base64, 'b32encode') self.mox.StubOutWithMock(util, 'Exec') self.mox.StubOutWithMock(keychain, 'Remove') base64.b32encode(mox.IsA(basestring)).AndReturn(mock_passphrase) util.Exec(mox.In('/usr/bin/certtool'), mox.IsA(basestring)).AndReturn( (0, '', '')) open_(mox.IsA(basestring), 'r').AndReturn(mock_full_keychain_file) mock_full_keychain_file.read().AndReturn(mock_full_keychain) keychain.Remove() util.Exec(mox.In('/usr/bin/security')).AndReturn((0, '', '')) util.Exec(mox.In('/usr/bin/certtool')).AndReturn((0, '', '')) open_(mox.IsA(basestring), 'r').AndReturn(mock_pub_keychain_file) mock_pub_keychain_file.read().AndReturn(mock_pub_keychain) mox.Replay(open_) self.mox.ReplayAll() self.assertEquals( (mock_pub_keychain, mock_full_keychain, mock_passphrase), keychain.Create(open_=open_)) self.mox.VerifyAll() mox.Verify(open_)
def test_record_messages(): conn = mox.MockObject(impl_kombu.Connection) conn.declare_topic_consumer('notifications.info', mox.IsA(types.FunctionType)) conn.consume() mox.Replay(conn) notificationclient.record_messages(conn, 'notifications.info', StringIO()) mox.Verify(conn)
def _testLocation(self, base, contextPath, servletPath, pathInfo): request = self.createNonIncludeRequest(base, contextPath, servletPath, pathInfo) # Set request into replay mode mox.Replay(request) location = getattr(self.servlet, 'getStaticFilesLocation', request) return location
def test_create_volume_from_snapshot_bigger(self): self.esm_mock.create_volume_from_snapshot( fake_volume, fake_snapshot).AndReturn(True) self.esm_mock.resize_volume(fake_volume_name, '20').AndReturn(True) mox.Replay(self.esm_mock) self.esm_mock.create_volume_from_snapshot(fake_volume, fake_snapshot) self.esm_mock.resize_volume(fake_volume_name, '20') mox.Verify(self.esm_mock)
def doTestRunStateChanges(self, initial_runstate, end_runstate, attrname, do_selected=True): """test calling attrname with both a single and multi-selection of projects. Sets initial run state of the projects, and confirms it gets switched to end_runstate. Args: initial_runstate: the initial run state of the Projects end_runstate: the end run state of the Projects after the op attrname: call this attribute for each project do_selected: if True, do mock a SelectedProjects() call. """ plists = (self.Projects(1), self.Projects(4)) for projectlist in plists: for p in projectlist: p.runstate = initial_runstate tc = launcher.TaskController(FakeAppController()) tc.SetModelsViews(runtime=launcher.Runtime()) stateop = getattr(tc, attrname) self.assertTrue(callable(stateop)) # Override thread creation; don't want real tasks running tc._CreateTaskThreadForProject = self._CreateTaskThreadForProject # Mock out "selected projects" of the frame to return projectlist frame_mock = mox.MockObject(launcher.MainFrame) if do_selected: frame_mock.SelectedProjects().AndReturn(projectlist) mox.Replay(frame_mock) tc.SetModelsViews(frame=frame_mock) # Finally, call the method we are testing, and verify stateop(None) mox.Verify(frame_mock) self.ConfirmThreads(end_runstate) # re-run our op and make sure no threads are modified/added/removed tmlen = len(self.threads) mox.Reset(frame_mock) if do_selected: frame_mock.SelectedProjects().AndReturn(projectlist) mox.Replay(frame_mock) stateop(None) mox.Verify(frame_mock) self.assertEqual(tmlen, len(self.threads)) self.ConfirmThreads(end_runstate)
def test_readdir_dir_not_exists(self): DIRPATH = '/DIR' cacheManagerMock = self.sut.cacheManager = mox.MockObject( cachefs.CacheManager) cacheManagerMock.exists(DIRPATH).AndReturn(False) mox.Replay(cacheManagerMock) self.assertEqual(None, self.sut.readdir(DIRPATH).next())
def test_opendir_path_not_exists(self): DIRPATH = '/DIR' cacheManagerMock = self.sut.cacheManager = mox.MockObject( cachefs.CacheManager) cacheManagerMock.exists(DIRPATH).AndReturn(False) mox.Replay(cacheManagerMock) self.assertEqual(-errno.ENOENT, self.sut.opendir(DIRPATH))
def test_update_joint_small_negative_error(self): self.mockJoint.getAngle().AndReturn(0) self.mockJoint.setLengthRate(Lt(0)) mox.Replay(self.mockJoint) #this kludge is to get around issues with expressing -.1 in floating point self.assertTrue(abs(-.1 - self.control.updateJoint(-.1, .1)) < .005) mox.Verify(self.mockJoint)
def testCancel(self): """Dialog comes up but is then cancelled.""" dialog_mock = mox.MockObject(launcher.PreferenceView) dialog_mock.ShowModal().AndReturn(wx.ID_CANCEL) dialog_mock.Destroy() mox.Replay(dialog_mock) pc = FakeController(self.prefs, dialog_mock) pc.ShowModal() mox.Verify(dialog_mock)
def _testIncludedLocation(self, base, portletContextPath, servletPath, pathInfo): request = self.createIncludeRequest(base, portletContextPath, servletPath, pathInfo) # Set request into replay mode mox.Replay(request) location = self._getStaticFilesLocationMethod(self.servlet, request) return location
def test_opendir_not_dir(self): FILEPATH = '/FILE' cacheManagerMock = self.sut.cacheManager = mox.MockObject( cachefs.CacheManager) cacheManagerMock.exists(FILEPATH).AndReturn(True) cacheManagerMock.isDirectory(FILEPATH).AndReturn(False) mox.Replay(cacheManagerMock) self.assertEqual(-errno.ENOENT, self.sut.opendir(FILEPATH))
def test_opendir_success(self): DIRPATH = '/DIR' cacheManagerMock = self.sut.cacheManager = mox.MockObject( cachefs.CacheManager) cacheManagerMock.exists(DIRPATH).AndReturn(True) cacheManagerMock.isDirectory(DIRPATH).AndReturn(True) mox.Replay(cacheManagerMock) self.assertEqual(None, self.sut.opendir(DIRPATH))
def _FindOrCreateConsoleLogs(self, project): """Override of TaskController's method to return a mock. For use with testLogs, below. """ console = mox.MockObject(launcher.LogConsole) console.DisplayAndBringToFront() self.consoles.append(console) mox.Replay(console) return console
def _FindOrCreateConsoleDPO(self, project): """Override of TaskController's method to return a mock. For use with testDisplayProjectOutput, below. """ self.assertTrue(project == 'momproject') self.console = mox.MockObject(launcher.LogConsole) self.console.AppendText('hi') mox.Replay(self.console) return self.console