aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_cucutags.py
blob: 7ae82ec5c7e5fed5ab2fab48e495e6127529cb81 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-  IGNORE:C0111
from __future__ import absolute_import, print_function, unicode_literals
import os.path
import cucutags
import unittest
import logging


class TestCucutags(unittest.TestCase):
    def setUp(self):
        self.maxDiff = None
        self.datadir = os.path.join(os.path.dirname(__file__), "data")
        self.session = cucutags.Session(self.datadir)
        logging.debug("session = %s", self.session)

    def test_init_session(self):
        """Just initialize Session from data in the data
        subdirectory."""
        self.assertIsInstance(self.session, cucutags.Session)

    def test_generate_tags(self):
        """Generate tags and compare with expected result."""
        tags = [tuple(x[1:]) for x in
                self.session.generate_tags(self.datadir)]
        expected = [(u'common_steps/app.py', 59),
                    (u'common_steps/gmenu.py', 12),
                    (u'common_steps/gmenu.py', 34),
                    (u'common_steps/app.py', 59),
                    (u'common_steps/app.py', 17),
                    (u'common_steps/app.py', 42),
                    (u'common_steps/app.py', 66),
                    (u'common_steps/app.py', 59),
                    (u'common_steps/gmenu.py', 12),
                    (u'common_steps/gmenu.py', 34),
                    (u'common_steps/app.py', 66)]
        self.assertEqual(tags, expected)

    def test_find_step(self):
        step = self.session.get_step(u"Make sure that Empathy is running")
        filename = os.path.relpath(step[0], os.path.dirname(__file__))
        self.assertEqual([filename, step[1]],
                         ["data/common_steps/app.py", 59])