Ejemplo n.º 1
0
 def test_save_same_meaning(self):
     last_set = Set.objects.all().order_by('-id')[0]
     message_to_edit = SetMessage.objects.filter(
         message_set__project_id=self.project.id,
         lang=self.project_language.id,
         message_set=last_set)[0]
     new_value = 'test'
     response = save_same(message_to_edit.id, new_value)
     self.assertEqual(SetMessage.objects.filter(id=message_to_edit.id)[0].msgstr, new_value)
Ejemplo n.º 2
0
    def test_change_value_after_import_in_one_project(self):
        path = os.path.join(PATH, 'data/mess.po')
        source_messages = SetMessage.objects.filter(
            msgstr='message1',
            lang=self.project_language.id)
        self.assertEqual(source_messages.count(), 2)

        import_po_file(path, self.project.id, self.project_language.id)
        import_po_file(path, self.new_project.id, self.project_language.id)
        source_messages = SetMessage.objects.filter(
            msgstr='title_title',
            lang=self.project_language.id)
        self.assertEqual(source_messages.count(), 2)
        message_to_edit = SetMessage.objects.get(
            message_set__project_id=self.project.id,
            msgid='1.Title',
            lang=self.project_language.id)

        #Check same meaning update
        new_value = 'message1 new'
        response = save_same(message_to_edit.id, new_value)
        source_messages = SetMessage.objects.filter(
            msgstr='message1 new',
            lang=self.project_language.id)
        self.assertEqual(source_messages.count(), 1)

        first_mes = get_message_list(self.project.id, self.project_language.id)
        second_mes = get_message_list(self.new_project.id, self.project_language.id)

        src_msg_list = {i['msg_id']: i['msg_source'] for i in first_mes}
        self.assertEqual(src_msg_list['1.Title'], 'message1 new')

        src_msg_list = {i['msg_id']: i['msg_source'] for i in second_mes}
        self.assertEqual(src_msg_list['1.Title'], 'title_title')

        #Check new meaning update
        new_value = 'message1 new2'
        response = save_new(message_to_edit.id, new_value)
        source_messages = SetMessage.objects.filter(
            msgstr='message1 new2',
            lang=self.project_language.id)
        self.assertEqual(source_messages.count(), 1)
        first_mes = get_message_list(self.project.id, self.project_language.id)
        second_mes = get_message_list(self.new_project.id, self.project_language.id)

        src_msg_list = {i['msg_id']: i['msg_source'] for i in first_mes}
        self.assertEqual(src_msg_list['1.Title'], 'message1 new2')

        src_msg_list = {i['msg_id']: i['msg_source'] for i in second_mes}
        self.assertEqual(src_msg_list['1.Title'], 'title_title')
Ejemplo n.º 3
0
 def test_change_value_in_one_project(self):
     message_to_edit = SetMessage.objects.get(
         message_set__project_id=self.project.id,
         msgid='mes.sag.e1',
         lang=self.project_language.id)
     source_messages = SetMessage.objects.filter(
         msgstr='message1',
         lang=self.project_language.id)
     self.assertEqual(source_messages.count(), 2)
     new_value = 'message1 new'
     response = save_same(message_to_edit.id, new_value)
     source_messages = SetMessage.objects.filter(
         msgstr='message1 new',
         lang=self.project_language.id)
     self.assertEqual(source_messages.count(), 1)