def test_filter_files(self): from pysvn import wc_notify_action as wcna from pysvn import Revision from core.controllers.auto_update.auto_update import os client = self.client override(os.path, 'isdir').expects(dontcare()).returns(False) set_count(exactly=2) ## Stop recording. Play! self.replay() # Call client's callback function several times f1 = '/path/to/file/foo.py' ev = {'action': wcna.update_delete, 'error': None, 'mime_type': None, 'path': f1, 'revision': Revision(pysvn.opt_revision_kind.number, 11)} client._register(ev) f2 = '/path/to/file/foo2.py' ev2 = {'action': wcna.update_update, 'error': None, 'mime_type': None, 'path': f2, 'revision': Revision(pysvn.opt_revision_kind.number, 11)} client._register(ev2) expected_res = SVNFilesList([(f1, FILE_DEL), (f2, FILE_UPD)]) self.assertEquals(expected_res, client._filter_files(filterbyactions=w3afSVNClient.UPD_ACTIONS)) ## Verify ## self.verify()
def test_filter_files(self): from pysvn import wc_notify_action as wcna from pysvn import Revision os = get_autoupdate_os_module() client = self.client override(os.path, "isdir").expects(dontcare()).returns(False) set_count(exactly=2) ## Stop recording. Play! self.replay() # Call client's callback function several times f1 = "/path/to/file/foo.py" ev = { "action": wcna.update_delete, "error": None, "mime_type": None, "path": f1, "revision": Revision(pysvn.opt_revision_kind.number, 11), } client._register(ev) f2 = "/path/to/file/foo2.py" ev2 = { "action": wcna.update_update, "error": None, "mime_type": None, "path": f2, "revision": Revision(pysvn.opt_revision_kind.number, 11), } client._register(ev2) expected_res = SVNFilesList([(f1, FILE_DEL), (f2, FILE_UPD)]) self.assertEquals(expected_res, client._filter_files(filterbyactions=w3afSVNClient.UPD_ACTIONS)) ## Verify ## self.verify()
def test_non_svn_install(self): """ Ensure that SVNError is raised when `get_svnversion` is called in a non svn copy. """ os = get_autoupdate_os_module() override(os, "walk").expects(dontcare()).returns(()) self.replay() self.assertRaises(SVNError, get_svnversion, (W3AF_LOCAL_PATH,))
def test_get_svnversion_with_non_svn_path(self): os = get_autoupdate_os_module() override(os, "walk").expects(dontcare()).generates(*([("x", "y", "z")] * 3)) cli = self.cli Rev = TestSVNVersion.Rev method(cli, "info").expects(dontcare()).returns({"revision": Rev(22)}) method(cli, "info").expects(dontcare()).returns({"revision": Rev(23)}) # If at least a 2-level depth non svn subdirectory is # found the pysvn client raises an exception method(cli, "info").expects(dontcare()).raises(pysvn.ClientError) ## Stop recording - Replay ## self.replay() self.assertEquals("22:23", get_svnversion(W3AF_LOCAL_PATH)) ## Verify ## self.verify()