Ejemplo n.º 1
0
    def test_put_and_get_single_msg(self):
        expected = 'Ящик'
        msg_collection = MsgCollection()
        msg_collection.add_msg(id='Box', str='Ящик')

        result = msg_collection.get_msg('Box').str

        self.assertEqual(expected, result)
Ejemplo n.º 2
0
 def execute(self, line, msg_collection: MsgCollection):
     msgstr_1 = line.split('msgstr[2]')[1].strip().strip('"')
     if msg_collection.current_msg:
         current_id = msg_collection.current_msg.id
         msg = msg_collection.get_msg(current_id)
         msg.add_str(msgstr_1)
         return
     raise ValueError()
Ejemplo n.º 3
0
    def test_put_and_get_plural_msg(self):
        expected = ['Ящик', 'Ящики']
        msg_collection = MsgCollection()
        msg_collection.add_msg_plural(id='Box',
                                      id_plural='Boxes',
                                      strs=['Ящик', 'Ящики'])

        result = msg_collection.get_msg('Box').strs

        self.assertEqual(expected, result)
Ejemplo n.º 4
0
    def test_add_str_to(self):
        expected = Msg(id='Box', str='Коробка')

        msg_collection = MsgCollection()
        msg_collection.add_msg(id='Box', str='Ящик')
        msg_collection.add_str_to(id='Box', str='Коробка')

        result = msg_collection.get_msg(id='Box')

        self.assertEqual(expected, result)
Ejemplo n.º 5
0
    def test_add_msg_with_paths(self):
        expected = ['../modules/user/x.js:112', '../modules/user/x.js:300']
        msg_collection = MsgCollection()
        msg_collection.add_msg(
            id='Box',
            str='Ящик',
            paths=['../modules/user/x.js:112', '../modules/user/x.js:300'])

        box = msg_collection.get_msg('Box')
        result = [p for p in box.paths]

        self.assertEqual(expected, result)
Ejemplo n.º 6
0
 def execute(self, line, msg_collection: MsgCollection):
     msgid_plural = line.split('msgid_plural')[1].strip().strip('"')
     if msg_collection.current_msg:
         current_id = msg_collection.current_msg.id
         current_paths = msg_collection.current_msg.paths
         msg_collection.remove_msg(current_id)
         msg_collection.add_msg_plural(id=current_id,
                                       id_plural=msgid_plural,
                                       strs=[],
                                       paths=current_paths)
         msg_collection.current_msg = msg_collection.get_msg(id=current_id)
         return
     raise ValueError()
Ejemplo n.º 7
0
    def test_add_path_to(self):
        expected = Msg(
            id='Box',
            str='Ящик',
            paths=['../modules/user/x.js:112', '../modules/user/x.js:300'])

        msg_collection = MsgCollection()
        msg_collection.add_msg(id='Box', str='Ящик')
        msg_collection.add_path_to(id='Box', path='../modules/user/x.js:112')
        msg_collection.add_path_to(id='Box', path='../modules/user/x.js:300')

        result = msg_collection.get_msg(id='Box')

        self.assertEqual(expected, result)