Esempio n. 1
0
 def setup_wrapper(self, args=frozenset()):
     with nested(
             mock.patch.object(hacheck, 'spool', return_value=(True, {})),
             mock.patch.object(hacheck.haupdown, 'print_s'),
             mock.patch('sys.argv', ['ignored'] + list(args))
     ) as (mock_spool, mock_print, _1):
         yield mock_spool, mock_print
Esempio n. 2
0
    def test_spool_post(self):
        with nested(
                mock.patch.dict(config.config,
                                {'allow_remote_spool_changes': True}),
                mock.patch.object(spool, 'up'),
                mock.patch.object(spool, 'down'),
        ) as (_1, spool_up, spool_down):

            response = self.fetch('/spool/foo/0/status',
                                  method='POST',
                                  body="status=up")
            self.assertEqual(response.code, 200)
            spool_up.assert_called_once_with('foo', port=None)

            response = self.fetch('/spool/foo/1234/status',
                                  method='POST',
                                  body="status=down&reason=because")
            self.assertEqual(response.code, 200)
            spool_down.assert_called_once_with('foo',
                                               reason='because',
                                               port=1234,
                                               expiration=None,
                                               creation=None)

            spool_down.reset_mock()
            response = self.fetch(
                '/spool/foo/1234/status',
                method='POST',
                body="status=down&reason=because&expiration=1&creation=2")
            self.assertEqual(response.code, 200)
            spool_down.assert_called_once_with('foo',
                                               reason='because',
                                               port=1234,
                                               expiration=1,
                                               creation=2)
Esempio n. 3
0
 def test_option_parsing(self):
     with nested(
         mock.patch('sys.argv', ['ignorethis', '-c', self.config_file.name, '--spool-root', 'foo']),
         mock.patch.object(tornado.ioloop.IOLoop, 'instance'),
         mock.patch.object(cache, 'configure'),
         mock.patch.object(main, 'get_app'),
         mock.patch.object(spool, 'configure')) \
             as (_1, _2, cache_configure, _3, spool_configure):
         main.main()
         spool_configure.assert_called_once_with(spool_root='foo')
         cache_configure.assert_called_once_with(cache_time=100)
Esempio n. 4
0
 def test_option_parsing(self):
     with nested(
         mock.patch('sys.argv', ['ignorethis', '-c', self.config_file.name, '--spool-root', 'foo']),
         mock.patch.object(tornado.ioloop.IOLoop, 'instance'),
         mock.patch.object(cache, 'configure'),
         mock.patch.object(main, 'get_app'),
         mock.patch.object(spool, 'configure')) \
             as (_1, _2, cache_configure, _3, spool_configure):
         main.main()
         spool_configure.assert_called_once_with(spool_root='foo')
         cache_configure.assert_called_once_with(cache_time=100)