def testTskPathType(self): mock_client = mock.MagicMock() with mock.patch.object(magics_impl._state, 'client', mock_client): magics_impl.grr_wget_impl('/foo/bar', path_type=magics_impl.TSK) mock_client.tsk.wget.assert_called_once_with('/foo/bar')
def testRegistryPathType(self): mock_client = mock.MagicMock() with mock.patch.object(magics_impl._state, 'client', mock_client): magics_impl.grr_wget_impl('/foo/bar', path_type=magics_impl.REGISTRY) mock_client.registry.wget.assert_called_once_with('/foo/bar')
def testCached(self): mock_client = mock.MagicMock() with mock.patch.object(magics_impl._state, 'client', mock_client): with mock.patch.object(magics_impl._state, 'cur_dir', '/quux'): magics_impl.grr_wget_impl('/foo/bar', cached=True) mock_client.os.cached.wget.assert_called_once_with('/foo/bar')
def testRelativePath(self): mock_client = mock.MagicMock() with mock.patch.object(magics_impl._state, 'client', mock_client): with mock.patch.object(magics_impl._state, 'cur_dir', '/quux'): magics_impl.grr_wget_impl('foo/bar') mock_client.os.wget.assert_called_once_with('/quux/foo/bar')
def grr_wget(line): """Downloads a file and returns a link to it. Args: line: A string representing arguments passed to the magic command. Returns: A link to the file. Raises: NoClientSelectedError: Client is not selected to perform this operation. """ args = grr_wget.parser.parse_args(shlex.split(line)) return magics_impl.grr_wget_impl(args.path, args.cached)
def testNoClientSelected(self): with self.assertRaises(magics_impl.NoClientSelectedError): magics_impl.grr_wget_impl('foo')