author David Douard <david.douard@logilab.fr>
Sun, 26 Oct 2014 18:30:36 +0100
changeset 1736 72ec6c7e956c
parent 1549 46be4dfc1070
child 1606 c7e928c1ed0e
permissions -rw-r--r--
[apycotlib] port to narval 4.2 The connection handler is now a CWProxy (cwclientlib), and there is no CreateSubEntity view any more since we can now create File entity using cwclientlib and rqlcontroller.

"""unit tests for the apycotlib.writer module"""

import os
from logilab.common.testlib import TestCase, unittest_main

import cubicweb.devtools
from cubes.apycot.testutils import MockConnection

from apycotlib.writer import BaseDataWriter

class BaseDataWriterTC(TestCase):

    def setUp(self):
        self.writer = BaseDataWriter(MockConnection('narval0'), 1)

    def test__msg_info_01(self):
        path, line, msg = self.writer._msg_info('bonjour %s', 'vous')
        self.assertEqual(path, None)
        self.assertEqual(line, None)
        self.assertEqual(msg, 'bonjour vous')

    def test__msg_info_02(self):
        path, line, msg = self.writer._msg_info('bonjour %s', 'vous', path='/tmp', line=1)
        self.assertEqual(path, '/tmp')
        self.assertEqual(line, 1)
        self.assertEqual(msg, 'bonjour vous')

    def test__msg_info_03(self):
            path, line, msg = self.writer._msg_info('oops %s', 'badaboum', tb=True)
        self.assertEqual(path, None)
        self.assertEqual(line, None)
        self.assertTrue(msg.startswith('oops badaboum'))
        self.assertTrue('Traceback' in msg)

if __name__ == '__main__':