Exemple #1
0
class TestDialect(unittest.TestCase):
    def setUp(self):
        self.A = Dialect({'dialect': 'A', 'package': '{}/tests.py'.format(os.path.abspath(os.path.dirname(__file__))), 'class': 'LineA'})
        self.B = Dialect({'dialect': 'B', 'package': '{}/tests.py'.format(os.path.abspath(os.path.dirname(__file__))), 'class': 'LineB'})
        self.dialects = [self.A, self.B]

    def test_success_parse_line(self):
        str_line = u'2016-01-01 14:32,noxy_production,22'
        line = self.A.parse(str_line)
        self.assertTrue(isinstance(line, self.A._class))

    def test_failure_parse_line(self):
        str_line = u'2016-01-01 14:32 22'
        with self.assertRaises(Exception):
            self.A.parse(str_line)

    def test_not_detect_dialect(self):
        line = get_dialect(self.dialects, u'2016-01-01 14:32,22')
        self.assertIsNone(line)

    def test_detect_first_dialect(self):
        line = get_dialect(self.dialects, u'2016-01-01 14:32,noxy_production,22')
        self.assertTrue(isinstance(line, self.A._class))

    def test_detect_next_dialect(self):
        line = get_dialect(self.dialects, u'2016-01-01 14:32|22')
        self.assertTrue(isinstance(line, self.B._class))
Exemple #2
0
 def setUp(self):
     self.A = Dialect({
         'dialect':
         'A',
         'package':
         '{}/tests.py'.format(os.path.abspath(os.path.dirname(__file__))),
         'class':
         'LineA'
     })
     self.B = Dialect({
         'dialect':
         'B',
         'package':
         '{}/tests.py'.format(os.path.abspath(os.path.dirname(__file__))),
         'class':
         'LineB'
     })
     self.dialects = [self.A, self.B]
Exemple #3
0
class TestDialect(unittest.TestCase):
    def setUp(self):
        self.A = Dialect({
            'dialect':
            'A',
            'package':
            '{}/tests.py'.format(os.path.abspath(os.path.dirname(__file__))),
            'class':
            'LineA'
        })
        self.B = Dialect({
            'dialect':
            'B',
            'package':
            '{}/tests.py'.format(os.path.abspath(os.path.dirname(__file__))),
            'class':
            'LineB'
        })
        self.dialects = [self.A, self.B]

    def test_success_parse_line(self):
        str_line = u'2016-01-01 14:32,noxy_production,22'
        line = self.A.parse(str_line)
        self.assertTrue(isinstance(line, self.A._class))

    def test_failure_parse_line(self):
        str_line = u'2016-01-01 14:32 22'
        with self.assertRaises(Exception):
            self.A.parse(str_line)

    def test_not_detect_dialect(self):
        line = get_dialect(self.dialects, u'2016-01-01 14:32,22')
        self.assertIsNone(line)

    def test_detect_first_dialect(self):
        line = get_dialect(self.dialects,
                           u'2016-01-01 14:32,noxy_production,22')
        self.assertTrue(isinstance(line, self.A._class))

    def test_detect_next_dialect(self):
        line = get_dialect(self.dialects, u'2016-01-01 14:32|22')
        self.assertTrue(isinstance(line, self.B._class))
Exemple #4
0
 def setUp(self):
     self.A = Dialect({'dialect': 'A', 'package': '{}/tests.py'.format(os.path.abspath(os.path.dirname(__file__))), 'class': 'LineA'})
     self.B = Dialect({'dialect': 'B', 'package': '{}/tests.py'.format(os.path.abspath(os.path.dirname(__file__))), 'class': 'LineB'})
     self.dialects = [self.A, self.B]