def test_fake_open_write(self): self.mox.ReplayAll() with self.assertRaises(OSError) as cm: stubs.fake_open(__file__, os.O_RDWR) self.mox.VerifyAll() e = cm.exception self.assertEqual(errno.EROFS, e.errno) self.assertEqual('Read-only file system', e.strerror) self.assertEqual(__file__, e.filename) self.mox.VerifyAll()
def test_fake_open_write(self): stubs.FakeFile.is_file_accessible(__file__, 2).AndReturn( stubs.FakeFile.Visibility.WRITE_BLOCK) self.mox.ReplayAll() with self.assertRaises(OSError) as cm: stubs.fake_open(__file__, os.O_RDWR) self.mox.VerifyAll() e = cm.exception self.assertEqual(errno.EROFS, e.errno) self.assertEqual('Read-only file system', e.strerror) self.assertEqual(__file__, e.filename) self.mox.VerifyAll()
def test_fake_open_inaccessible(self): stubs.FakeFile.is_file_accessible(__file__, 0).AndReturn( stubs.FakeFile.Visibility.STATIC_BLOCK) logging.info('Sandbox prevented access to static file "%s"', __file__) logging.info( 'Check that `application_readable: true` is set in app.yaml') self.mox.ReplayAll() with self.assertRaises(OSError) as cm: stubs.fake_open(__file__, os.O_RDONLY) self.mox.VerifyAll() e = cm.exception self.assertEqual(errno.ENOENT, e.errno) self.assertEqual('No such file or directory', e.strerror) self.assertEqual(__file__, e.filename) self.mox.VerifyAll()
def test_fake_open_inaccessible(self): stubs.FakeFile.is_file_accessible(__file__).AndReturn( stubs.FakeFile.Visibility.STATIC_BLOCK) logging.info('Sandbox prevented access to static file "%s"', __file__) logging.info( 'Check that `application_readable: true` is set in app.yaml') self.mox.ReplayAll() with self.assertRaises(OSError) as cm: stubs.fake_open(__file__, os.O_RDONLY) self.mox.VerifyAll() e = cm.exception self.assertEqual(errno.ENOENT, e.errno) self.assertEqual('No such file or directory', e.strerror) self.assertEqual(__file__, e.filename) self.mox.VerifyAll()
def test_fake_open_accessible(self): stubs.FakeFile.is_file_accessible(__file__, 0).AndReturn( stubs.FakeFile.Visibility.OK) self.mox.ReplayAll() os.close(stubs.fake_open(__file__, os.O_RDONLY)) self.mox.VerifyAll()
def test_fake_open_accessible(self): stubs.FakeFile.is_file_accessible(__file__).AndReturn( stubs.FakeFile.Visibility.OK) self.mox.ReplayAll() os.close(stubs.fake_open(__file__, os.O_RDONLY)) self.mox.VerifyAll()