def test_get_missing_media_list(self): image_path = 'jr://file/commcare/case_list_image.jpg' self.master_app_with_report_modules.get_module(0).set_icon('en', image_path) self.master_app_with_report_modules.create_mapping(self.image, image_path, save=False) with patch('corehq.apps.hqmedia.models.CommCareMultimedia.get', side_effect=ResourceNotFound): missing_media = _get_missing_multimedia(self.master_app_with_report_modules) media_item = list(self.master_app_with_report_modules.multimedia_map.values())[0] self.assertEqual(missing_media, [('case_list_image.jpg', media_item)])
def test_get_missing_media_list(self): image_path = 'jr://file/commcare/case_list_image.jpg' self.master_app_with_report_modules.get_module(0).set_icon('en', image_path) self.master_app_with_report_modules.create_mapping(self.image, image_path, save=False) with patch('corehq.apps.hqmedia.models.CommCareMultimedia.get', side_effect=ResourceNotFound): missing_media = _get_missing_multimedia(self.master_app_with_report_modules) media_item = list(self.master_app_with_report_modules.multimedia_map.values())[0] self.assertEqual(missing_media, [('case_list_image.jpg', media_item)])
def test_add_domain_to_media(self): self.image.valid_domains.remove(self.master_app_with_report_modules.domain) self.image.save() image = CommCareImage.get(self.image._id) self.assertNotIn(self.master_app_with_report_modules.domain, image.valid_domains) image_path = 'jr://file/commcare/case_list_image.jpg' self.master_app_with_report_modules.get_module(0).set_icon('en', image_path) self.master_app_with_report_modules.create_mapping(self.image, image_path, save=False) missing_media = _get_missing_multimedia(self.master_app_with_report_modules) self.assertEqual(missing_media, []) image = CommCareImage.get(self.image._id) self.assertIn(self.master_app_with_report_modules.domain, image.valid_domains)
def test_add_domain_to_media(self): self.image.valid_domains.remove(self.master_app_with_report_modules.domain) self.image.save() image = CommCareImage.get(self.image._id) self.assertNotIn(self.master_app_with_report_modules.domain, image.valid_domains) image_path = 'jr://file/commcare/case_list_image.jpg' self.master_app_with_report_modules.get_module(0).set_icon('en', image_path) self.master_app_with_report_modules.create_mapping(self.image, image_path, save=False) missing_media = _get_missing_multimedia(self.master_app_with_report_modules) self.assertEqual(missing_media, []) image = CommCareImage.get(self.image._id) self.assertIn(self.master_app_with_report_modules.domain, image.valid_domains)