def test_size_increased_by_put(self):
     buf = status_lib.line_buffer()
     self.assertEquals(buf.size(), 0)
     buf.put("1")
     buf.put("2")
     self.assertEquals(buf.size(), 2)
     buf.put("3")
     self.assertEquals(buf.size(), 3)
Esempio n. 2
0
 def test_size_increased_by_put(self):
     buf = status_lib.line_buffer()
     self.assertEquals(buf.size(), 0)
     buf.put("1")
     buf.put("2")
     self.assertEquals(buf.size(), 2)
     buf.put("3")
     self.assertEquals(buf.size(), 3)
Esempio n. 3
0
 def test_is_fifo(self):
     buf = status_lib.line_buffer()
     lines = ["line #%d" for x in xrange(10)]
     for line in lines:
         buf.put(line)
     results = []
     while buf.size():
         results.append(buf.get())
     self.assertEquals(lines, results)
 def test_is_fifo(self):
     buf = status_lib.line_buffer()
     lines = ["line #%d" for x in xrange(10)]
     for line in lines:
         buf.put(line)
     results = []
     while buf.size():
         results.append(buf.get())
     self.assertEquals(lines, results)
Esempio n. 5
0
 def start(self, job):
     """ Initialize the parser for processing the results of
     'job'."""
     # initialize all the basic parser parameters
     self.job = job
     self.finished = False
     self.line_buffer = status_lib.line_buffer()
     # create and prime the parser state machine
     self.state = self.state_iterator(self.line_buffer)
     self.state.next()
Esempio n. 6
0
 def start(self, job):
     """ Initialize the parser for processing the results of
     'job'."""
     # initialize all the basic parser parameters
     self.job = job
     self.finished = False
     self.line_buffer = status_lib.line_buffer()
     # create and prime the parser state machine
     self.state = self.state_iterator(self.line_buffer)
     self.state.next()
Esempio n. 7
0
 def test_size_decreased_by_get(self):
     buf = status_lib.line_buffer()
     buf.put("1")
     buf.put("2")
     buf.put("3")
     self.assertEqual(buf.size(), 3)
     buf.get()
     self.assertEqual(buf.size(), 2)
     buf.get()
     buf.get()
     self.assertEqual(buf.size(), 0)
Esempio n. 8
0
 def test_put_back_is_lifo(self):
     buf = status_lib.line_buffer()
     lines = ["1", "2", "3"]
     for line in lines:
         buf.put(line)
     results = []
     results.append(buf.get())
     buf.put_back("1")
     buf.put_back("0")
     while buf.size():
         results.append(buf.get())
     self.assertEquals(results, ["1", "0", "1", "2", "3"])
 def test_put_back_is_lifo(self):
     buf = status_lib.line_buffer()
     lines = ["1", "2", "3"]
     for line in lines:
         buf.put(line)
     results = []
     results.append(buf.get())
     buf.put_back("1")
     buf.put_back("0")
     while buf.size():
         results.append(buf.get())
     self.assertEquals(results, ["1", "0", "1", "2", "3"])
Esempio n. 10
0
 def test_put_multiple_same_as_multiple_puts(self):
     buf_put, buf_multi = [status_lib.line_buffer() for x in xrange(2)]
     lines = ["line #%d" % x for x in xrange(10)]
     for line in lines:
         buf_put.put(line)
     buf_multi.put_multiple(lines)
     counter = 0
     while buf_put.size():
         self.assertEquals(buf_put.size(), buf_multi.size())
         line = "line #%d" % counter
         self.assertEquals(buf_put.get(), line)
         self.assertEquals(buf_multi.get(), line)
         counter += 1
Esempio n. 11
0
 def test_put_multiple_same_as_multiple_puts(self):
     buf_put, buf_multi = [status_lib.line_buffer()
                           for x in xrange(2)]
     lines = ["line #%d" % x for x in xrange(10)]
     for line in lines:
         buf_put.put(line)
     buf_multi.put_multiple(lines)
     counter = 0
     while buf_put.size():
         self.assertEquals(buf_put.size(), buf_multi.size())
         line = "line #%d" % counter
         self.assertEquals(buf_put.get(), line)
         self.assertEquals(buf_multi.get(), line)
         counter += 1
Esempio n. 12
0
 def test_get_single(self):
     buf = status_lib.line_buffer()
     buf.put("single line")
     self.assertEquals(buf.get(), "single line")
     self.assertRaises(IndexError, buf.get)
Esempio n. 13
0
 def test_get_empty(self):
     buf = status_lib.line_buffer()
     self.assertRaises(IndexError, buf.get)
Esempio n. 14
0
 def test_get_single(self):
     buf = status_lib.line_buffer()
     buf.put("single line")
     self.assertEquals(buf.get(), "single line")
     self.assertRaises(IndexError, buf.get)
Esempio n. 15
0
 def test_get_empty(self):
     buf = status_lib.line_buffer()
     self.assertRaises(IndexError, buf.get)