def test_get_latest_activity_no_latest(self): """ If the matching ProjectLocale has no latest_translation, return None. """ ProjectLocaleFactory.create(project=self.project, locale=self.locale, latest_translation=None) assert_is_none(ProjectLocale.get_latest_activity(self.project, self.locale))
def test_get_latest_activity_success(self): """ If the matching ProjectLocale has a latest_translation, return it's latest_activity. """ translation = TranslationFactory.create(locale=self.locale, entity__resource__project=self.project) ProjectLocaleFactory.create(project=self.project, locale=self.locale, latest_translation=translation) assert_equal(ProjectLocale.get_latest_activity(self.project, self.locale), translation.latest_activity)
def test_get_latest_activity_no_latest(self): """ If the matching ProjectLocale has no latest_translation, return None. """ ProjectLocaleFactory.create(project=self.project, locale=self.locale, latest_translation=None) assert_is_none( ProjectLocale.get_latest_activity(self.project, self.locale))
def test_project_locale_added(self): """ When a locale is added to a project, has_changed should be set to True. """ project = ProjectFactory.create(locales=[], has_changed=False) assert_false(project.has_changed) locale = LocaleFactory.create() ProjectLocaleFactory.create(project=project, locale=locale) project.refresh_from_db() assert_true(project.has_changed)
def test_get_latest_activity_success(self): """ If the matching ProjectLocale has a latest_translation, return it's latest_activity. """ translation = TranslationFactory.create( locale=self.locale, entity__resource__project=self.project) ProjectLocaleFactory.create(project=self.project, locale=self.locale, latest_translation=translation) assert_equal( ProjectLocale.get_latest_activity(self.project, self.locale), translation.latest_activity)
def private_project_locale(): yield ProjectLocaleFactory.create()
def public_project_locale(): yield ProjectLocaleFactory.create(project__visibility="public")
def public_project_locale(): yield ProjectLocaleFactory.create(project__visibility=Project.Visibility.PUBLIC)