Example #1
0
class Test(unittest.TestCase):
    def setUp(self):
        self.telnet = MockTelnet()
        self.beanstalkd = Beanstalkd(self.telnet, 'thehost', 9057)
                        
    def test_connect(self):
        self.beanstalkd.connect()
        self.assertTrue(self.telnet.openCalled)        
        
    def test_yaml_data(self):
        line = self.beanstalkd.yaml_data("stats")
        self.assertEquals({'current-jobs-ready': 5, 'current-waiting': 12, 'current-workers': 4,  'pid':1223}, line)
        
    def test_yaml_data_filtered(self):
        line = self.beanstalkd.yaml_data_filtered("stats",  ["current-jobs-ready",  "current-waiting"])
        self.assertEquals({'current-jobs-ready': 5, 'current-waiting': 12}, line)
Example #2
0
    def setUp(self):
        self.mock_telnet = MockTelnet()
        self.mock_os = MockOs()
        self.mock_file = MockFile()
        self.mock_file.char = 'q'
        self.mock_time = MockTime()
        self.mock_sys = MockSys(self.mock_file)
        self.mock_termios = MockTermios()
        self.mock_fcntl = MockFcntl()

        self.beanstalkd = Beanstalkd(self.mock_telnet, '', '')
        self.stats = BeanstalkdStats(self.beanstalkd)
        self.char_reader = CharReader(self.mock_os, self.mock_sys,
                                      self.mock_termios, self.mock_fcntl)
        self.screen_printer = ScreenPrinter(self.mock_os, self.mock_sys)
        self.console = Console(Clock(self.mock_time), self.char_reader,
                               self.screen_printer, self.stats)
Example #3
0
class Test(unittest.TestCase):
    def setUp(self):
        self.mock_telnet = MockTelnet()
        self.mock_os = MockOs()
        self.mock_file = MockFile()
        self.mock_file.char = 'q'
        self.mock_time = MockTime()
        self.mock_sys = MockSys(self.mock_file)
        self.mock_termios = MockTermios()
        self.mock_fcntl = MockFcntl()

        self.beanstalkd = Beanstalkd(self.mock_telnet, '', '')
        self.stats = BeanstalkdStats(self.beanstalkd)
        self.char_reader = CharReader(self.mock_os, self.mock_sys,
                                      self.mock_termios, self.mock_fcntl)
        self.screen_printer = ScreenPrinter(self.mock_os, self.mock_sys)
        self.console = Console(Clock(self.mock_time), self.char_reader,
                               self.screen_printer, self.stats)

    def test_integration(self):
        self.beanstalkd.connect()
        self.console.main_loop()
Example #4
0
 def setUp(self):
     self.telnet = MockTelnet()
     self.beanstalkd = Beanstalkd(self.telnet, 'thehost', 9057)