def get_capabilities(self, api_root): """Retrieve Capabilities from the server and return them.""" info = api_root.get_info() if 'capabilities' in info: return Capabilities(info.capabilities) else: return Capabilities({})
def test_has_capability_with_partial_path(self): """Testing Capabilities.has_capability with partial capability path""" caps = Capabilities({'foo': { 'bar': { 'value': True, } }}) self.assertFalse(caps.has_capability('foo', 'bar'))
def test_has_capability(self): """Testing Capabilities.has_capability with supported capability""" caps = Capabilities({'foo': { 'bar': { 'value': True, } }}) self.assertTrue(caps.has_capability('foo', 'bar', 'value'))
def test_has_capability_with_partial_path(self): """Testing Capabilities.has_capability with partial capability path""" caps = Capabilities({ 'foo': { 'bar': { 'value': True, } } }) self.assertFalse(caps.has_capability('foo', 'bar'))
def test_has_capability(self): """Testing Capabilities.has_capability with supported capability""" caps = Capabilities({ 'foo': { 'bar': { 'value': True, } } }) self.assertTrue(caps.has_capability('foo', 'bar', 'value'))
def get_capabilities(self, api_root): """Retrieve Capabilities from the server and return them.""" if 'capabilities' in api_root: # Review Board 2.0+ provides capabilities in the root resource. return Capabilities(api_root.capabilities) info = api_root.get_info() if 'capabilities' in info: return Capabilities(info.capabilities) else: return Capabilities({})
def _test_diff_with_moved_files(self, expected_diff_hash, caps={}): client = self._build_client() client.capabilities = Capabilities(caps) client.p4.repo_files = [ { 'depotFile': '//mydepot/test/README', 'rev': '2', 'action': 'move/delete', 'change': '12345', 'text': 'This is a test.\n', }, { 'depotFile': '//mydepot/test/README-new', 'rev': '1', 'action': 'move/add', 'change': '12345', 'text': 'This is a mess.\n', }, { 'depotFile': '//mydepot/test/COPYING', 'rev': '2', 'action': 'move/delete', 'change': '12345', 'text': 'Copyright 2013 Joe User.\n', }, { 'depotFile': '//mydepot/test/COPYING-new', 'rev': '1', 'action': 'move/add', 'change': '12345', 'text': 'Copyright 2013 Joe User.\n', }, ] readme_file = make_tempfile() copying_file = make_tempfile() readme_file_new = make_tempfile() copying_file_new = make_tempfile() client.p4.print_file('//mydepot/test/README#2', readme_file) client.p4.print_file('//mydepot/test/COPYING#2', copying_file) client.p4.print_file('//mydepot/test/README-new#1', readme_file_new) client.p4.print_file('//mydepot/test/COPYING-new#1', copying_file_new) client.p4.where_files = { '//mydepot/test/README': readme_file, '//mydepot/test/COPYING': copying_file, '//mydepot/test/README-new': readme_file_new, '//mydepot/test/COPYING-new': copying_file_new, } client.p4.fstat_files = { '//mydepot/test/README': { 'clientFile': readme_file, 'movedFile': '//mydepot/test/README-new', }, '//mydepot/test/README-new': { 'clientFile': readme_file_new, 'depotFile': '//mydepot/test/README-new', }, '//mydepot/test/COPYING': { 'clientFile': copying_file, 'movedFile': '//mydepot/test/COPYING-new', }, '//mydepot/test/COPYING-new': { 'clientFile': copying_file_new, 'depotFile': '//mydepot/test/COPYING-new', }, } revisions = client.parse_revision_spec(['12345']) diff = client.diff(revisions) self._compare_diff(diff, expected_diff_hash)
def test_has_capability_with_unknown_capability(self): """Testing Capabilities.has_capability with unknown capability""" caps = Capabilities({}) self.assertFalse(caps.has_capability('mycap'))
def get_capabilities(self, api_root): """Retrieve Capabilities from the server and return them.""" return Capabilities(api_root.get_info().capabilities)