Exemplo n.º 1
0
class TestSimplePhoneLogs_full_example_file(unittest.TestCase):

    logmodule = False

    def setUp(self):

        result_file = os.path.dirname(os.path.abspath(
            __file__)) + os.path.sep + "sample-phonelog-result-TEMP.org"

        self.test_file = os.path.dirname(
            os.path.abspath(__file__)) + os.sep + "tmp" \
            + os.path.sep + "sample-phonelog.csv"

        self.argv = "-s -f " + self.test_file + " --output " + result_file

        self.logmodule = SimplePhoneLogsMemacs(argv=self.argv.split())
        self.logmodule.handle_main()

    def test_determine_opposite_eventname(self):

        self.assertEqual(self.logmodule._determine_opposite_eventname(u"boot"),
                         u'shutdown')
        self.assertEqual(
            self.logmodule._determine_opposite_eventname(u'shutdown'), u'boot')
        self.assertEqual(self.logmodule._determine_opposite_eventname(u'foo'),
                         u'foo-end')
        self.assertEqual(
            self.logmodule._determine_opposite_eventname(u'foo-end'), u'foo')

    def test_parser(self):

        result_file = os.path.dirname(os.path.abspath(
            __file__)) + os.path.sep + "sample-phonelog-result-TEMP.org"

        argv = "-f " + self.test_file + \
            " --output " + result_file

        localmodule = SimplePhoneLogsMemacs(argv=argv.split())
        localmodule.handle_main()

        result_from_module = CommonReader.get_data_from_file(result_file)

        result_from_module_without_header_and_last_line = u''
        for line in result_from_module.split('\n'):
            if line.startswith(u'* successfully parsed ') or \
                    line.startswith(u'#') or \
                    line.startswith(u'* '):
                pass
            else:
                result_from_module_without_header_and_last_line += line + '\n'

        ## self.reference_result is defined below!
        self.assertEqual(result_from_module_without_header_and_last_line,
                         self.reference_result)

        os.remove(result_file)

    maxDiff = None  ## show also large diff

    reference_result = u"""** <2012-11-20 Tue 11:56> boot
class TestSimplePhoneLogs_full_example_file(unittest.TestCase):

    logmodule = False

    def setUp(self):

        result_file = os.path.dirname(
            os.path.abspath(__file__)) + os.path.sep + "sample-phonelog-result-TEMP.org"

        self.test_file = os.path.dirname(
            os.path.abspath(__file__)) + os.sep + "tmp" \
            + os.path.sep + "sample-phonelog.csv"

        self.argv = "-s -f " + self.test_file + " --output " + result_file

        self.logmodule = SimplePhoneLogsMemacs(argv = self.argv.split())
        self.logmodule.handle_main()


    def test_determine_opposite_eventname(self):

        self.assertEqual(self.logmodule._determine_opposite_eventname(u"boot"), u'shutdown')
        self.assertEqual(self.logmodule._determine_opposite_eventname(u'shutdown'), u'boot')
        self.assertEqual(self.logmodule._determine_opposite_eventname(u'foo'), u'foo-end')
        self.assertEqual(self.logmodule._determine_opposite_eventname(u'foo-end'), u'foo')


    def test_parser(self):

        result_file = os.path.dirname(
            os.path.abspath(__file__)) + os.path.sep + "sample-phonelog-result-TEMP.org"

        argv = "-f " + self.test_file + \
            " --output " + result_file

        localmodule = SimplePhoneLogsMemacs(argv = argv.split())
        localmodule.handle_main()

        result_from_module = CommonReader.get_data_from_file(result_file)

        result_from_module_without_header_and_last_line = u''
        for line in result_from_module.split('\n'):
            if line.startswith(u'* successfully parsed ') or \
                    line.startswith(u'#') or \
                    line.startswith(u'* '):
                pass
            else:
                result_from_module_without_header_and_last_line += line + '\n'

        ## self.reference_result is defined below!
        self.assertEqual(result_from_module_without_header_and_last_line, self.reference_result)
        
        os.remove(result_file)



    maxDiff = None  ## show also large diff

    reference_result = u"""** <2012-11-20 Tue 11:56> boot
Exemplo n.º 3
0
class TestSimplePhoneLogsFull(PhoneLogsTestCase):

    logmodule = False

    def setUp(self):
        super(TestSimplePhoneLogsFull, self).setUp()
        self.test_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'data',
            'sample-phonelog.csv')
        self.argv = "-s -f " + self.test_file + " --output " + self.result_file
        self.logmodule = SimplePhoneLogsMemacs(argv=self.argv.split())
        self.logmodule.handle_main()

    def test_determine_opposite_eventname(self):

        self.assertEqual(self.logmodule._determine_opposite_eventname("boot"),
                         'shutdown')
        self.assertEqual(
            self.logmodule._determine_opposite_eventname('shutdown'), 'boot')
        self.assertEqual(self.logmodule._determine_opposite_eventname('foo'),
                         'foo-end')
        self.assertEqual(
            self.logmodule._determine_opposite_eventname('foo-end'), 'foo')

    def test_parser(self):

        argv = "-f " + self.test_file + \
            " --output " + self.result_file

        localmodule = SimplePhoneLogsMemacs(argv=argv.split())
        localmodule.handle_main()

        result = self.get_result_from_file()
        self.assertEqual(result, self.reference_result)

    maxDiff = None  ## show also large diff

    reference_result = """** <2012-11-20 Tue 11:56> boot
Exemplo n.º 4
0
class TestSimplePhoneLogsFull(PhoneLogsTestCase):

    logmodule = False

    def setUp(self):
        super(TestSimplePhoneLogsFull, self).setUp()
        self.test_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            'data', 'sample-phonelog.csv'
        )
        self.argv = "-s -f " + self.test_file + " --output " + self.result_file
        self.logmodule = SimplePhoneLogsMemacs(argv = self.argv.split())
        self.logmodule.handle_main()

    def test_determine_opposite_eventname(self):

        self.assertEqual(self.logmodule._determine_opposite_eventname(u"boot"), u'shutdown')
        self.assertEqual(self.logmodule._determine_opposite_eventname(u'shutdown'), u'boot')
        self.assertEqual(self.logmodule._determine_opposite_eventname(u'foo'), u'foo-end')
        self.assertEqual(self.logmodule._determine_opposite_eventname(u'foo-end'), u'foo')


    def test_parser(self):

        argv = "-f " + self.test_file + \
            " --output " + self.result_file

        localmodule = SimplePhoneLogsMemacs(argv = argv.split())
        localmodule.handle_main()

        result = self.get_result_from_file()
        self.assertEqual(result, self.reference_result)

    maxDiff = None  ## show also large diff

    reference_result = u"""** <2012-11-20 Tue 11:56> boot