Exemplo n.º 1
0
    def test_latest_activity(self):
        """Ensure that the latest_activity field is added to parts."""
        locale = LocaleFactory.create(code='test')
        project = ProjectFactory.create(locales=[locale], slug='test-project')
        resource = ResourceFactory.create(project=project, path='has/stats.po')
        translation = TranslationFactory.create(entity__resource=resource,
                                                locale=locale)
        StatsFactory.create(resource=resource,
                            locale=locale,
                            latest_translation=translation)

        with patch.object(Project, 'locales_parts_stats') as mock_locales_parts_stats, \
                patch('pontoon.base.views.render') as mock_render:
            mock_locales_parts_stats.return_value = [{
                'resource__path':
                'has/stats.po'
            }, {
                'resource__path':
                'no/stats.po'
            }]

            views.locale_project(self.factory.get('/'),
                                 locale='test',
                                 slug='test-project')
            ctx = mock_render.call_args[0][2]
            assert_equal(ctx['parts'], [{
                'resource__path': 'has/stats.po',
                'latest_activity': translation
            }, {
                'resource__path': 'no/stats.po',
                'latest_activity': None
            }])
Exemplo n.º 2
0
    def test_latest_activity(self):
        """Ensure that the latest_activity field is added to parts."""
        locale = LocaleFactory.create(code='test')
        project = ProjectFactory.create(locales=[locale], slug='test-project')
        resource = ResourceFactory.create(project=project, path='has/stats.po')
        translation = TranslationFactory.create(entity__resource=resource, locale=locale)
        StatsFactory.create(resource=resource, locale=locale, latest_translation=translation)

        with patch.object(Project, 'locales_parts_stats') as mock_locales_parts_stats, \
                patch('pontoon.base.views.render') as mock_render:
            mock_locales_parts_stats.return_value = [
                {'resource__path': 'has/stats.po'},
                {'resource__path': 'no/stats.po'}
            ]

            views.locale_project(self.factory.get('/'), locale='test', slug='test-project')
            ctx = mock_render.call_args[0][2]
            assert_equal(ctx['parts'], [
                {'resource__path': 'has/stats.po', 'latest_activity': translation},
                {'resource__path': 'no/stats.po', 'latest_activity': None}
            ])
Exemplo n.º 3
0
    def test_latest_activity(self):
        """Ensure that the latest_activity field is added to parts."""
        locale = LocaleFactory.create(code='test')
        project = ProjectFactory.create(locales=[locale], slug='test-project')
        resource = ResourceFactory.create(project=project, path='has/stats.po')
        translation = TranslationFactory.create(entity__resource=resource, locale=locale)
        TranslatedResourceFactory.create(resource=resource, locale=locale, latest_translation=translation)

        with patch.object(Locale, 'parts_stats') as mock_parts_stats, \
                patch('pontoon.base.views.render') as mock_render:
            mock_parts_stats.return_value = [
                {
                    'title': 'has/stats.po',
                    'resource__path': 'has/stats.po',
                    'resource__total_strings': 1,
                    'approved_strings': 0,
                    'translated_strings': 1,
                    'fuzzy_strings': 0,
                },
                {
                    'title': 'no/stats.po',
                    'resource__path': 'no/stats.po',
                    'resource__total_strings': 1,
                    'approved_strings': 0,
                    'translated_strings': 0,
                    'fuzzy_strings': 0,
                }
            ]

            views.locale_project(self.factory.get('/'), locale='test', slug='test-project')
            ctx = mock_render.call_args[0][2]
            assert_equal(ctx['parts'], [
                {
                    'latest_activity': translation.latest_activity,
                    'title': 'has/stats.po',
                    'resource__path': 'has/stats.po',
                    'resource__total_strings': 1,
                    'approved_strings': 0,
                    'translated_strings': 1,
                    'fuzzy_strings': 0,
                    'chart': {
                        'fuzzy_strings': 0,
                        'total_strings': 1,
                        'approved_strings': 0,
                        'translated_strings': 1,
                        'approved_share': 0.0,
                        'translated_share': 100.0,
                        'fuzzy_share': 0.0,
                        'approved_percent': 0
                    }
                },
                {
                    'latest_activity': None,
                    'title': 'no/stats.po',
                    'resource__path': 'no/stats.po',
                    'resource__total_strings': 1,
                    'approved_strings': 0,
                    'translated_strings': 0,
                    'fuzzy_strings': 0,
                    'chart': {
                        'fuzzy_strings': 0,
                        'total_strings': 1,
                        'approved_strings': 0,
                        'translated_strings': 0,
                        'approved_share': 0.0,
                        'translated_share': 0.0,
                        'fuzzy_share': 0.0,
                        'approved_percent': 0
                    }
                }
            ])
Exemplo n.º 4
0
    def test_latest_activity(self):
        """Ensure that the latest_activity field is added to parts."""
        locale = LocaleFactory.create(code='test')
        project = ProjectFactory.create(locales=[locale], slug='test-project')
        resource = ResourceFactory.create(project=project, path='has/stats.po')
        translation = TranslationFactory.create(entity__resource=resource,
                                                locale=locale)
        TranslatedResourceFactory.create(resource=resource,
                                         locale=locale,
                                         latest_translation=translation)

        with patch.object(Locale, 'parts_stats') as mock_parts_stats, \
                patch('pontoon.base.views.render') as mock_render:
            mock_parts_stats.return_value = [{
                'title': 'has/stats.po',
                'resource__path': 'has/stats.po',
                'resource__total_strings': 1,
                'approved_strings': 0,
                'translated_strings': 1,
                'fuzzy_strings': 0,
            }, {
                'title': 'no/stats.po',
                'resource__path': 'no/stats.po',
                'resource__total_strings': 1,
                'approved_strings': 0,
                'translated_strings': 0,
                'fuzzy_strings': 0,
            }]

            views.locale_project(self.factory.get('/'),
                                 locale='test',
                                 slug='test-project')
            ctx = mock_render.call_args[0][2]
            assert_equal(ctx['parts'], [{
                'latest_activity': translation,
                'title': 'has/stats.po',
                'resource__path': 'has/stats.po',
                'resource__total_strings': 1,
                'approved_strings': 0,
                'translated_strings': 1,
                'fuzzy_strings': 0,
                'chart': {
                    'fuzzy_strings': 0,
                    'total_strings': 1,
                    'approved_strings': 0,
                    'translated_strings': 1,
                    'approved_share': 0.0,
                    'translated_share': 100.0,
                    'fuzzy_share': 0.0,
                    'approved_percent': 0
                }
            }, {
                'latest_activity': None,
                'title': 'no/stats.po',
                'resource__path': 'no/stats.po',
                'resource__total_strings': 1,
                'approved_strings': 0,
                'translated_strings': 0,
                'fuzzy_strings': 0,
                'chart': {
                    'fuzzy_strings': 0,
                    'total_strings': 1,
                    'approved_strings': 0,
                    'translated_strings': 0,
                    'approved_share': 0.0,
                    'translated_share': 0.0,
                    'fuzzy_share': 0.0,
                    'approved_percent': 0
                }
            }])