from django.test import SimpleTestCase
from django.test.utils import override_settings
from corehq.apps.app_manager.models import Application
from corehq.apps.app_manager.tests.util import TestFileMixin
from corehq.apps.hqmedia.models import CommCareImage


class MediaSuiteTest(SimpleTestCase, TestFileMixin):
    file_path = ('data', 'suite')

    @override_settings(BASE_ADDRESS='192.cc.hq.1')
    def test_csae_list_media(self):
        app = Application.wrap(self.get_json('app'))
        app.get_module(0).case_list_form.form_id = app.get_module(0).get_form(0).unique_id

        image_path = 'jr://file/commcare/case_list_image.jpg'
        audo_path = 'jr://file/commcare/case_list_audo.mp3'
        app.get_module(0).case_list_form.media_image = image_path
        app.get_module(0).case_list_form.media_audio = audo_path

        app.create_mapping(CommCareImage(_id='123'), image_path, save=False)
        app.create_mapping(CommCareImage(_id='456'), audo_path, save=False)

        self.assertXmlEqual(self.get_xml('media_suite'), app.create_media_suite())

@@ -80,16 +80,65 @@
 ettings%0A
+from corehq.apps.app_manager.const import APP_V2%0A
 from cor
@@ -183,16 +183,24 @@
 lication
+, Module
 %0Afrom co
@@ -1036,16 +1036,16 @@
 False)%0A%0A
-
         
@@ -1119,8 +1119,1067 @@
 uite())%0A
+%0A    def test_localized_media(self):%0A        image_path = 'jr://file/commcare/case_list_image.jpg'%0A        audio_path = 'jr://file/commcare/case_list_audo.mp3'%0A%0A        app = Application.new_app('domain', %22my app%22, application_version=APP_V2)%0A        module = app.add_module(Module.new_module(%22Module 1%22, None))%0A        app.new_form(0, %22Form 1%22, None)%0A%0A        module.set_icon('en', image_path)%0A        module.set_audio('en', audio_path)%0A%0A        XML = %22%22%22%0A        %3Cpartial%3E%0A            %3Centry%3E%0A              %3Ccommand id=%22m0-f0%22%3E%0A                %3Cdisplay%3E%0A                  %3Ctext%3E%0A                    %3Clocale id=%22forms.m0f0%22/%3E%0A                  %3C/text%3E%0A                  %3Ctext form=%22image%22%3E%0A                    %3Clocale id=%22forms.m0f0.icon%22/%3E%0A                  %3C/text%3E%0A                  %3Ctext form=%22audio%22%3E%0A                    %3Clocale id=%22forms.m0f0.audio%22/%3E%0A                  %3C/text%3E%0A                %3C/display%3E%0A              %3C/command%3E%0A            %3C/entry%3E%0A        %3C/partial%3E%0A        %22%22%22%0A        self.assertXmlPartialEqual(XML, app.create_suite(), %22./entry%22)%0A

Add basic localized media test