def test_mark_translation_availability_required_no_fallback_field_missing(self):
     model = MockTranslatableModel()
     model.fallback1 = "english value 1"
     model.nofallback1 = "english value 2"
     with translation.override("de"):
         # Don't populate the field "nofallback1" which does not have fallback enabled
         model.fallback1 = "german value 1"
     TranslatableModelLoader.mark_translation_availability(model, required_fields=["fallback1", "nofallback1"])
     self.assertSetEqual(set(["en"]), set(model.languages))
 def test_mark_translation_availability_all_required_fields_present(self):
     model = MockTranslatableModel()
     model.fallback1 = "english value 1"
     model.nofallback1 = "english value 2"
     with translation.override("de"):
         model.fallback1 = "german value 1"
         model.nofallback1 = "german value 2"
     TranslatableModelLoader.mark_translation_availability(model, required_fields=["fallback1", "nofallback1"])
     self.assertSetEqual(set(["en", "de"]), set(model.languages))
 def test_mark_translation_availability_required_fields_not_given(self):
     model = MockTranslatableModel()
     with mock.patch("utils.language_utils.get_available_languages", return_value=["en", "de", "fr"]):
         TranslatableModelLoader.mark_translation_availability(model)
     self.assertSetEqual(set(get_available_languages()), set(model.languages))