Example #1
0
    def testRoot(self):
        mock_client = _MockClient()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            cur_dir = magics_impl.grr_pwd_impl()

        self.assertEqual(cur_dir, '/')
Example #2
0
    def testNonRootPath(self):
        mock_client = _MockClient()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            with mock.patch.object(magics_impl._state, 'cur_dir', '/foo/bar'):
                cur_dir = magics_impl.grr_pwd_impl()

        self.assertEqual(cur_dir, '/foo/bar')
Example #3
0
def grr_pwd(line: Text) -> Text:
    """Returns absolute path to the current directory.

  Args:
    line: A string representing arguments passed to the magic command.

  Returns:
    Absolute path to the current directory.

  Raises:
    NoClientSelectedError: Client is not selected to perform this operation.
  """
    del line  # Unused.
    return magics_impl.grr_pwd_impl()
Example #4
0
 def testNoClientSelected(self):
     with self.assertRaises(magics_impl.NoClientSelectedError):
         magics_impl.grr_pwd_impl()