コード例 #1
0
ファイル: test_callables.py プロジェクト: xiangfu0/hacheck
 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
コード例 #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)
コード例 #3
0
ファイル: test_application.py プロジェクト: xiangfu0/hacheck
 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)
コード例 #4
0
ファイル: test_application.py プロジェクト: c-buisson/hacheck
 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)