Пример #1
0
def stat(request, _):
    """Stat a path."""
    if not os.path.exists(request.path):
        return untrusted_runner_pb2.StatResponse(result=False)

    stat_result = os.stat(request.path)
    return untrusted_runner_pb2.StatResponse(result=True,
                                             st_mode=stat_result.st_mode,
                                             st_size=stat_result.st_size,
                                             st_atime=stat_result.st_atime,
                                             st_mtime=stat_result.st_mtime,
                                             st_ctime=stat_result.st_ctime)
Пример #2
0
  def test_stat_error(self):
    """Test file_host.stat error."""
    result = untrusted_runner_pb2.StatResponse(
        result=False, st_mode=0, st_size=1, st_atime=2, st_mtime=3, st_ctime=4)

    self.mock.stub().Stat.return_value = result
    self.assertIsNone(file_host.stat('/path'))
Пример #3
0
  def test_stat(self):
    """Test file_host.stat."""
    result = untrusted_runner_pb2.StatResponse(
        result=True, st_mode=0, st_size=1, st_atime=2, st_mtime=3, st_ctime=4)

    self.mock.stub().Stat.return_value = result
    self.assertEqual(result, file_host.stat('/path'))