Exemplo n.º 1
0
    def setUpClass(cls):
        create_domain(cls.domain)
        toggles.MOBILE_UCR.set(cls.domain, True, toggles.NAMESPACE_DOMAIN)
        cls.user = CommCareUser.create(cls.domain, 'john_doe', 's3cr3t')

        cls.app1 = Application.new_app(cls.domain, 'Test App 1', application_version=APP_V2)
        cls.report_config1 = get_sample_report_config()
        cls.report_config1.save()
        report_app_config = {
            'report_id': cls.report_config1.get_id,
            'uuid': '123456'
        }
        module = cls.app1.add_module(ReportModule.new_module('Reports', None))
        module.report_configs = [ReportAppConfig.wrap(report_app_config)]
        cls.app1.save()

        cls.app2 = Application.new_app(cls.domain, 'Test App 2', application_version=APP_V2)
        cls.report_config2 = get_sample_report_config()
        cls.report_config2.save()
        report_app_config = {
            'report_id': cls.report_config2.get_id,
            'uuid': 'abcdef'
        }
        module = cls.app2.add_module(ReportModule.new_module('Reports', None))
        module.report_configs = [ReportAppConfig.wrap(report_app_config)]
        cls.app2.save()

        cls.app3 = Application.new_app(cls.domain, 'Test App 3', application_version=APP_V2)
        cls.app3.save()
Exemplo n.º 2
0
    def test_all_media_report_module(self):
        """
        Report Modules don't support media
        """
        from corehq.apps.userreports.tests import get_sample_report_config

        app = Application.new_app("domain", "Untitled Application", application_version=APP_V2)

        report_module = app.add_module(ReportModule.new_module("Reports", None))
        report_module.unique_id = "report_module"
        report = get_sample_report_config()
        report._id = "d3ff18cd83adf4550b35db8d391f6008"

        report_app_config = ReportAppConfig(report_id=report._id, header={"en": "CommBugz"})
        report_app_config._report = report
        report_module.report_configs = [report_app_config]
        report_module._loaded = True

        image_path = "jr://file/commcare/case_list_image.jpg"
        audio_path = "jr://file/commcare/case_list_audo.mp3"
        app.get_module(0).case_list_form.set_icon("en", image_path)
        app.get_module(0).case_list_form.set_audio("en", audio_path)

        self.assertFalse(app.get_module(0).uses_media())
        self.assertEqual(len(app.all_media), 0)
Exemplo n.º 3
0
    def test_all_media_report_module(self):
        """
        Report Modules don't support media
        """
        from corehq.apps.userreports.tests import get_sample_report_config

        app = Application.new_app('domain', "Untitled Application", application_version=APP_V2)

        report_module = app.add_module(ReportModule.new_module('Reports', None))
        report_module.unique_id = 'report_module'
        report = get_sample_report_config()
        report._id = 'd3ff18cd83adf4550b35db8d391f6008'

        report_app_config = ReportAppConfig(report_id=report._id,
                                            header={'en': 'CommBugz'})
        report_app_config._report = report
        report_module.report_configs = [report_app_config]
        report_module._loaded = True

        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

        self.assertFalse(app.get_module(0).uses_media())
        self.assertEqual(len(app.all_media), 0)
Exemplo n.º 4
0
    def test_all_media_report_module(self):
        """
        Report Modules don't support media
        """
        from corehq.apps.userreports.tests import get_sample_report_config

        app = Application.new_app('domain', "Untitled Application", application_version=APP_V2)

        report_module = app.add_module(ReportModule.new_module('Reports', None))
        report_module.unique_id = 'report_module'
        report = get_sample_report_config()
        report._id = 'd3ff18cd83adf4550b35db8d391f6008'

        report_app_config = ReportAppConfig(report_id=report._id,
                                            header={'en': 'CommBugz'})
        report_app_config._report = report
        report_module.report_configs = [report_app_config]
        report_module._loaded = True

        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

        self.assertFalse(app.get_module(0).uses_media())
        self.assertEqual(len(app.all_media), 0)
Exemplo n.º 5
0
    def test_report_module(self):
        from corehq.apps.userreports.tests import get_sample_report_config

        app = Application.new_app('domain', "Untitled Application", application_version=APP_V2)

        report_module = app.add_module(ReportModule.new_module('Reports', None))
        report_module.unique_id = 'report_module'
        report = get_sample_report_config()
        report._id = 'd3ff18cd83adf4550b35db8d391f6008'

        report_app_config = ReportAppConfig(
            report_id=report._id,
            header={'en': 'CommBugz'},
            uuid='ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i',
        )
        report_app_config._report = report
        report_module.report_configs = [report_app_config]
        report_module._loaded = True
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_menu'),
            app.create_suite(),
            "./menu",
        )
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_select_detail'),
            app.create_suite(),
            "./detail[@id='reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i.select']",
        )
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_summary_detail'),
            app.create_suite(),
            "./detail[@id='reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i.summary']",
        )
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_data_detail'),
            app.create_suite(),
            "./detail/detail[@id='reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i.data']",
        )
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_data_entry'),
            app.create_suite(),
            "./entry",
        )
        self.assertIn(
            'reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i=CommBugz',
            app.create_app_strings('default'),
        )
Exemplo n.º 6
0
    def test_report_module(self):
        from corehq.apps.userreports.tests import get_sample_report_config

        app = Application.new_app('domain',
                                  "Untitled Application",
                                  application_version=APP_V2)

        report_module = app.add_module(ReportModule.new_module(
            'Reports', None))
        report_module.unique_id = 'report_module'
        report = get_sample_report_config()
        report._id = 'd3ff18cd83adf4550b35db8d391f6008'

        report_app_config = ReportAppConfig(report_id=report._id,
                                            header={'en': 'CommBugz'})
        report_app_config._report = report
        report_module.report_configs = [report_app_config]
        report_module._loaded = True
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_menu'),
            app.create_suite(),
            "./menu",
        )
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_select_detail'),
            app.create_suite(),
            "./detail[@id='reports.d3ff18cd83adf4550b35db8d391f6008.select']",
        )
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_summary_detail'),
            app.create_suite(),
            "./detail[@id='reports.d3ff18cd83adf4550b35db8d391f6008.summary']",
        )
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_data_detail'),
            app.create_suite(),
            "./detail[@id='reports.d3ff18cd83adf4550b35db8d391f6008.data']",
        )
        self.assertXmlPartialEqual(
            self.get_xml('reports_module_data_entry'),
            app.create_suite(),
            "./entry",
        )
        self.assertIn(
            'reports.d3ff18cd83adf4550b35db8d391f6008=CommBugz',
            app.create_app_strings('default'),
        )