Ejemplo n.º 1
0
    def test_exceptions(self):
        q = SmartQueue(4)
        
        self.assertEqual(None, q.get_input_rpm())
        self.assertEqual(None, q.get_output_rpm())
        
        for i in xrange(4):
            q.put(i)
            # 20 RPM
            time.sleep(3)
        
        for _ in xrange(10):
            self.assertRaises(Queue.Full, q.put_nowait, None)
        
        self.assertEqual(q.qsize(), 4)
        
        self.assertGreater(q.get_input_rpm(), 19)
        self.assertLess(q.get_input_rpm(), 20)

        for i in xrange(4):
            q.get()
            # 60 RPM
            time.sleep(1)

        for _ in xrange(10):
            self.assertRaises(Queue.Empty, q.get_nowait)
        
        self.assertGreater(q.get_output_rpm(), 59)
        self.assertLess(q.get_output_rpm(), 60)
        self.assertEqual(q.qsize(), 0)
Ejemplo n.º 2
0
    def test_exceptions(self):
        q = SmartQueue(4)
        
        self.assertEqual(0.0, q.get_input_rpm())
        self.assertEqual(0.0, q.get_output_rpm())
        
        for i in xrange(4):
            q.put(i)
            # 20 RPM
            time.sleep(3)
        
        for _ in xrange(10):
            self.assertRaises(Queue.Full, q.put_nowait, None)
        
        self.assertEqual(q.qsize(), 4)
        
        self.assertGreater(q.get_input_rpm(), 19)
        self.assertLess(q.get_input_rpm(), 28)

        for i in xrange(4):
            q.get()
            # 60 RPM
            time.sleep(1)

        for _ in xrange(10):
            self.assertRaises(Queue.Empty, q.get_nowait)
        
        self.assertGreater(q.get_output_rpm(), 69)
        self.assertLess(q.get_output_rpm(), 80)
        self.assertEqual(q.qsize(), 0)
Ejemplo n.º 3
0
    def test_simple(self):
        q = SmartQueue()
        
        self.assertEqual(None, q.get_input_rpm())
        self.assertEqual(None, q.get_output_rpm())
        
        for i in xrange(4):
            q.put(i)
            # 20 RPM
            time.sleep(3)
        
        self.assertEqual(q.qsize(), 4)
        
        self.assertGreater(q.get_input_rpm(), 19)
        self.assertLess(q.get_input_rpm(), 20)

        for i in xrange(4):
            q.get()
            # 60 RPM
            time.sleep(1)
                        
        self.assertGreater(q.get_output_rpm(), 59)
        self.assertLess(q.get_output_rpm(), 60)
        self.assertEqual(q.qsize(), 0)
Ejemplo n.º 4
0
    def test_simple(self):
        q = SmartQueue()
        
        self.assertEqual(0.0, q.get_input_rpm())
        self.assertEqual(0.0, q.get_output_rpm())
        
        for i in xrange(4):
            q.put(i)
            # 20 RPM
            time.sleep(3)
        
        self.assertEqual(q.qsize(), 4)
        
        self.assertGreater(q.get_input_rpm(), 19)
        self.assertLess(q.get_input_rpm(), 28)

        for i in xrange(4):
            q.get()
            # 60 RPM
            time.sleep(1)
                        
        self.assertGreater(q.get_output_rpm(), 69)
        self.assertLess(q.get_output_rpm(), 80)
        self.assertEqual(q.qsize(), 0)
Ejemplo n.º 5
0
 def test_no_data(self):
     q = SmartQueue()
     
     for _ in xrange(10):
         self.assertEqual(None, q.get_input_rpm())
         self.assertEqual(None, q.get_output_rpm())
Ejemplo n.º 6
0
 def test_no_data(self):
     q = SmartQueue()
     
     for _ in xrange(10):
         self.assertEqual(0.0, q.get_input_rpm())
         self.assertEqual(0.0, q.get_output_rpm())