Ejemplo n.º 1
0
    def test_from_lxml_full(self):
        text = '''<STREAM location="path" cycle="123" cycle_gzip="NO">
  <FILTER>gzip</FILTER>
  <FILTER>bzip2</FILTER>
</STREAM>'''
        log = Stream.from_lxml_element(etree.XML(text))
        right = Stream('path', 123, False, ['gzip', 'bzip2'])
        self.assertEqual(log, right)
Ejemplo n.º 2
0
    def test_from_lxml_full(self):
        text = '''<STREAM location="path" cycle="123" cycle_gzip="NO">
  <FILTER>gzip</FILTER>
  <FILTER>bzip2</FILTER>
</STREAM>'''
        log = Stream.from_lxml_element(etree.XML(text))
        right = Stream('path', 123, False, ['gzip', 'bzip2'])
        self.assertEqual(log, right)
Ejemplo n.º 3
0
    def test_stream(self):
        text = '''
<STREAM custom="unknown">
  abc
  <UNKNOWN>
    <CUSTOM />
  </UNKNOWN>
</STREAM>'''
        stream = Stream.from_string(text)
        tree = stream.to_lxml_element()
        self.assertEqual('unknown', tree.get('custom'))
        unknown = tree.findall('UNKNOWN')
        self.assertEqual(1, len(unknown))
        unknown = unknown[0]
        custom = list(unknown)
        self.assertEqual(1, len(custom))
        custom = custom[0]
        self.assertEqual('CUSTOM', custom.tag)
Ejemplo n.º 4
0
    def test_stream(self):
        text = '''
<STREAM custom="unknown">
  abc
  <UNKNOWN>
    <CUSTOM />
  </UNKNOWN>
</STREAM>'''
        stream = Stream.from_string(text)
        tree = stream.to_lxml_element()
        self.assertEqual('unknown', tree.get('custom'))
        unknown = tree.findall('UNKNOWN')
        self.assertEqual(1, len(unknown))
        unknown = unknown[0]
        custom = list(unknown)
        self.assertEqual(1, len(custom))
        custom = custom[0]
        self.assertEqual('CUSTOM', custom.tag)
Ejemplo n.º 5
0
 def test_from_lxml_cycle(self):
     text = '<STREAM cycle="123" />'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream(cycle=123)
     self.assertEqual(log, right)
Ejemplo n.º 6
0
 def test_from_lxml_filters(self):
     text = '<STREAM><FILTER>gzip</FILTER><FILTER>bzip2</FILTER></STREAM>'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream(filters=['gzip', 'bzip2'])
     self.assertEqual(log, right)
Ejemplo n.º 7
0
 def test_from_string_location(self):
     text = '<STREAM location="path" />'
     log = Stream.from_string(text)
     right = Stream(location='path')
     self.assertEqual(log, right)
Ejemplo n.º 8
0
 def test_from_lxml(self):
     text = '<STREAM />'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream()
     self.assertEqual(log, right)
Ejemplo n.º 9
0
 def test_creation(self):
     log = Stream()
     log = Stream('/logs/MyServer.log')
     log = Stream('/logs/MyServer.log', 1048576)
     log = Stream('/logs/MyServer.log', 1048576, False)
     log = Stream('/logs/MyServer.log', 1048576, False, ['gzip', 'bzip2'])
Ejemplo n.º 10
0
 def test_cycle(self):
     log = Stream()
     self.assertEqual(None, log.get_cycle())
     log.set_cycle(123)
     self.assertEqual(123, log.get_cycle())
     log.set_cycle(None)
     self.assertEqual(None, log.get_cycle())
     log = Stream('path', 123)
     self.assertEqual(123, log.get_cycle())
     log = Stream(cycle=123)
     self.assertEqual(123, log.get_cycle())
Ejemplo n.º 11
0
 def test_to_string_cycle_gzip(self):
     log = Stream(cycle_gzip = False)
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 12
0
 def test_to_string_cycle_gzip(self):
     log = Stream(cycle_gzip=False)
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 13
0
 def test_to_string_location(self):
     log = Stream(location = 'path')
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 14
0
 def test_to_string_cycle(self):
     log = Stream(cycle = 123)
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 15
0
 def test_to_string(self):
     log = Stream()
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 16
0
 def test_from_lxml_location(self):
     text = '<STREAM location="path" />'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream(location = 'path')
     self.assertEqual(log, right)
Ejemplo n.º 17
0
 def test_from_lxml_filters(self):
     text = '<STREAM><FILTER>gzip</FILTER><FILTER>bzip2</FILTER></STREAM>'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream(filters = ['gzip', 'bzip2'])
     self.assertEqual(log, right)
Ejemplo n.º 18
0
 def test_equality(self):
     self.assertEqual(Stream('path', 123, False, ['gzip', 'bzip2']),
                      Stream('path', 123, False, ['gzip', 'bzip2']))
     self.assertNotEqual(Stream('path1', 123, False, ['gzip', 'bzip2']),
                         Stream('path2', 123, False, ['gzip', 'bzip2']))
     self.assertNotEqual(Stream('path', 1234, False, ['gzip', 'bzip2']),
                         Stream('path', 123, False, ['gzip', 'bzip2']))
     self.assertNotEqual(Stream('path', 123, True, ['gzip', 'bzip2']),
                         Stream('path', 123, False, ['gzip', 'bzip2']))
     self.assertNotEqual(Stream('path', 123, False, ['bzip2']),
                         Stream('path', 123, False, ['gzip', 'bzip2']))
     self.assertNotEqual([], Stream('path'))
Ejemplo n.º 19
0
 def test_to_string_filters(self):
     log = Stream(filters = ['gzip', 'bzip2'])
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 20
0
 def test_to_string_location(self):
     log = Stream(location='path')
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 21
0
 def test_to_string_full(self):
     log = Stream('path', 123, False, ['gzip', 'bzip2'])
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 22
0
 def test_from_lxml_cycle_gzip(self):
     text = '<STREAM cycle_gzip="NO" />'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream(cycle_gzip = False)
     self.assertEqual(log, right)
Ejemplo n.º 23
0
 def test_to_lxml_location(self):
     log = Stream(location = 'path')
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 24
0
 def test_location(self):
     log = Stream()
     self.assertEqual(None, log.get_location())
     log.set_location('/logs/new.log')
     self.assertEqual('/logs/new.log', log.get_location())
     log.set_location(None)
     self.assertEqual(None, log.get_location())
     log = Stream('/logs/MyServer.log')
     self.assertEqual('/logs/MyServer.log', log.get_location())
     log = Stream(location='/logs/MyServer.log')
     self.assertEqual('/logs/MyServer.log', log.get_location())
Ejemplo n.º 25
0
 def test_to_lxml_cycle(self):
     log = Stream(cycle = 123)
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 26
0
 def test_filters(self):
     log = Stream()
     self.assertEqual([], log.get_filters())
     log.add_filter('gzip')
     self.assertEqual(['gzip'], log.get_filters())
     log.add_filter('bzip2')
     self.assertEqual(['gzip', 'bzip2'], log.get_filters())
     log.add_filter('bzip2', 0)
     self.assertEqual(['bzip2', 'gzip', 'bzip2'], log.get_filters())
     self.assertEqual('gzip', log.get_filter(1))
     log.remove_filter(1)
     self.assertEqual(['bzip2', 'bzip2'], log.get_filters())
     log = Stream('path', 123, False, ['gzip'])
     self.assertEqual(['gzip'], log.get_filters())
     log = Stream(filters=['gzip'])
     self.assertEqual(['gzip'], log.get_filters())
Ejemplo n.º 27
0
 def test_to_lxml_cycle_gzip(self):
     log = Stream(cycle_gzip = False)
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 28
0
 def test_from_string_filters(self):
     text = '<STREAM><FILTER>gzip</FILTER><FILTER>bzip2</FILTER></STREAM>'
     log = Stream.from_string(text)
     right = Stream(filters = ['gzip', 'bzip2'])
     self.assertEqual(log, right)
Ejemplo n.º 29
0
 def test_to_lxml_filters(self):
     log = Stream(filters = ['gzip', 'bzip2'])
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 30
0
 def test_from_lxml_location(self):
     text = '<STREAM location="path" />'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream(location='path')
     self.assertEqual(log, right)
Ejemplo n.º 31
0
 def test_to_lxml_full(self):
     log = Stream('path', 123, False, ['gzip', 'bzip2'])
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 32
0
 def test_from_lxml_cycle_gzip(self):
     text = '<STREAM cycle_gzip="NO" />'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream(cycle_gzip=False)
     self.assertEqual(log, right)
Ejemplo n.º 33
0
 def test_location(self):
     log = Stream()
     self.assertEqual(None, log.get_location())
     log.set_location('/logs/new.log')
     self.assertEqual('/logs/new.log', log.get_location())
     log.set_location(None)
     self.assertEqual(None, log.get_location())
     log = Stream('/logs/MyServer.log')
     self.assertEqual('/logs/MyServer.log', log.get_location())
     log = Stream(location = '/logs/MyServer.log')
     self.assertEqual('/logs/MyServer.log', log.get_location())
Ejemplo n.º 34
0
 def test_from_lxml(self):
     text = '<STREAM />'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream()
     self.assertEqual(log, right)
Ejemplo n.º 35
0
 def test_to_string_full(self):
     log = Stream('path', 123, False, ['gzip', 'bzip2'])
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 36
0
 def test_to_string(self):
     log = Stream()
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 37
0
 def test_to_lxml_cycle(self):
     log = Stream(cycle=123)
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 38
0
 def test_to_string_cycle(self):
     log = Stream(cycle=123)
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 39
0
 def test_to_lxml_filters(self):
     log = Stream(filters=['gzip', 'bzip2'])
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 40
0
 def test_to_string_filters(self):
     log = Stream(filters=['gzip', 'bzip2'])
     copy = Stream.from_string(str(log))
     self.assertEqual(log, copy)
Ejemplo n.º 41
0
 def test_from_lxml_cycle(self):
     text = '<STREAM cycle="123" />'
     log = Stream.from_lxml_element(etree.XML(text))
     right = Stream(cycle = 123)
     self.assertEqual(log, right)
Ejemplo n.º 42
0
 def test_to_lxml_location(self):
     log = Stream(location='path')
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 43
0
 def test_cycle(self):
     log = Stream()
     self.assertEqual(None, log.get_cycle())
     log.set_cycle(123)
     self.assertEqual(123, log.get_cycle())
     log.set_cycle(None)
     self.assertEqual(None, log.get_cycle())
     log = Stream('path', 123)
     self.assertEqual(123, log.get_cycle())
     log = Stream(cycle = 123)
     self.assertEqual(123, log.get_cycle())
Ejemplo n.º 44
0
 def test_to_lxml_cycle_gzip(self):
     log = Stream(cycle_gzip=False)
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 45
0
 def test_cycle_gzip(self):
     log = Stream()
     self.assertEqual(None, log.get_cycle_gzip())
     log.set_cycle_gzip(True)
     self.assertEqual(True, log.get_cycle_gzip())
     log.set_cycle_gzip(None)
     self.assertEqual(None, log.get_cycle_gzip())
     log = Stream('path', 123, False)
     self.assertEqual(False, log.get_cycle_gzip())
     log = Stream(cycle_gzip = False)
     self.assertEqual(False, log.get_cycle_gzip())
Ejemplo n.º 46
0
 def test_to_lxml_full(self):
     log = Stream('path', 123, False, ['gzip', 'bzip2'])
     copy = Stream.from_lxml_element(log.to_lxml_element())
     self.assertEqual(log, copy)
Ejemplo n.º 47
0
 def test_filters(self):
     log = Stream()
     self.assertEqual([], log.get_filters())
     log.add_filter('gzip')
     self.assertEqual(['gzip'], log.get_filters())
     log.add_filter('bzip2')
     self.assertEqual(['gzip', 'bzip2'], log.get_filters())
     log.add_filter('bzip2', 0)
     self.assertEqual(['bzip2', 'gzip', 'bzip2'], log.get_filters())
     self.assertEqual('gzip', log.get_filter(1))
     log.remove_filter(1)
     self.assertEqual(['bzip2', 'bzip2'], log.get_filters())
     log = Stream('path', 123, False, ['gzip'])
     self.assertEqual(['gzip'], log.get_filters())
     log = Stream(filters = ['gzip'])
     self.assertEqual(['gzip'], log.get_filters())
Ejemplo n.º 48
0
 def setUp(self):
     self.stream_0 = Stream(location='file://logs/MyServerHTTP.log')
     self.stream_1 = Stream(location='console://stdout', filters=['gzip'])
Ejemplo n.º 49
0
 def test_from_string(self):
     text = '<STREAM />'
     log = Stream.from_string(text)
     right = Stream()
     self.assertEqual(log, right)
Ejemplo n.º 50
0
 def test_from_string_location(self):
     text = '<STREAM location="path" />'
     log = Stream.from_string(text)
     right = Stream(location = 'path')
     self.assertEqual(log, right)
Ejemplo n.º 51
0
 def test_from_string_cycle(self):
     text = '<STREAM cycle="123" />'
     log = Stream.from_string(text)
     right = Stream(cycle = 123)
     self.assertEqual(log, right)
Ejemplo n.º 52
0
 def test_cycle_gzip(self):
     log = Stream()
     self.assertEqual(None, log.get_cycle_gzip())
     log.set_cycle_gzip(True)
     self.assertEqual(True, log.get_cycle_gzip())
     log.set_cycle_gzip(None)
     self.assertEqual(None, log.get_cycle_gzip())
     log = Stream('path', 123, False)
     self.assertEqual(False, log.get_cycle_gzip())
     log = Stream(cycle_gzip=False)
     self.assertEqual(False, log.get_cycle_gzip())
Ejemplo n.º 53
0
 def test_from_string_cycle_gzip(self):
     text = '<STREAM cycle_gzip="NO" />'
     log = Stream.from_string(text)
     right = Stream(cycle_gzip=False)
     self.assertEqual(log, right)
Ejemplo n.º 54
0
 def test_from_string(self):
     text = '<STREAM />'
     log = Stream.from_string(text)
     right = Stream()
     self.assertEqual(log, right)
Ejemplo n.º 55
0
 def test_from_string_filters(self):
     text = '<STREAM><FILTER>gzip</FILTER><FILTER>bzip2</FILTER></STREAM>'
     log = Stream.from_string(text)
     right = Stream(filters=['gzip', 'bzip2'])
     self.assertEqual(log, right)
Ejemplo n.º 56
0
 def test_from_string_cycle(self):
     text = '<STREAM cycle="123" />'
     log = Stream.from_string(text)
     right = Stream(cycle=123)
     self.assertEqual(log, right)
Ejemplo n.º 57
0
 def test_from_string_cycle_gzip(self):
     text = '<STREAM cycle_gzip="NO" />'
     log = Stream.from_string(text)
     right = Stream(cycle_gzip = False)
     self.assertEqual(log, right)