Beispiel #1
0
 def testIsPanicModeNoPackages(self):
   """Test IsPanicModeNoPackages()."""
   self.mox.StubOutWithMock(common, 'IsPanicMode')
   common.IsPanicMode(common.PANIC_MODE_NO_PACKAGES).AndReturn(123)
   self.mox.ReplayAll()
   self.assertEqual(123, common.IsPanicModeNoPackages())
   self.mox.VerifyAll()
Beispiel #2
0
  def testIsPanicMode(self):
    """Tests IsPanicMode()."""
    mode = common.PANIC_MODES[0]
    k = '%s%s' % (common.PANIC_MODE_PREFIX, mode)

    self.mox.StubOutWithMock(
        common.models.KeyValueCache, 'MemcacheWrappedGet')

    common.models.KeyValueCache.MemcacheWrappedGet(k).AndReturn(1)
    common.models.KeyValueCache.MemcacheWrappedGet(k).AndReturn(None)

    self.mox.ReplayAll()
    self.assertTrue(common.IsPanicMode(mode))
    self.assertFalse(common.IsPanicMode(mode))
    self.assertRaises(ValueError, common.IsPanicMode, 'never a mode')
    self.mox.VerifyAll()
Beispiel #3
0
  def testPostWhenVerifyEnable(self, *_):
    mode = 'no_packages'

    resp = self.testapp.post(
        '/admin/panic', {'mode': mode, 'enabled': 'enable', 'verify': 1},
        status=httplib.FOUND)

    self.assertTrue(resp.headers['Location'].endswith('/admin/panic'))
    self.assertTrue(common.IsPanicMode(mode))
Beispiel #4
0
    def get(self):
        """GET handler."""
        if not self.IsAdminUser():
            return

        modes = []
        for mode in common.PANIC_MODES:
            d = {
                'name': mode,
                'enabled': common.IsPanicMode(mode),
            }
            modes.append(d)

        self.Render('panic.html', {'modes': modes, 'report_type': 'panic'})