Exemple #1
0
    def test_download_file_bad_xform_404(self):
        '''
        This tests that the `download_file` view returns
        HTTP code 404 for XML that cannot be generated...
        in some sense it does not exist.
        '''

        module = self.app.add_module(Module.new_module("Module0", "en"))

        # These builds are checked in to the repo for use in tests
        build1 = {'version': '1.2.dev', 'build_number': 7106}
        build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**build1)
        add_build(**build2)

        with open(
                os.path.join(os.path.dirname(__file__), "data",
                             "invalid_form.xml")) as f:
            xform_str = f.read()
        self.app.new_form(module.id,
                          name="Form0-0",
                          attachment=xform_str,
                          lang="en")
        self.app.save()

        response = self.client.get(
            reverse('app_download_file',
                    kwargs=dict(domain=self.domain.name,
                                app_id=self.app.get_id,
                                path='modules-0/forms-0.xml')))
        self.assertEqual(response.status_code, 404)
    def setUp(self):
        self.domain = 'test-domain'
        create_domain(self.domain)
        self.app = Application.new_app(self.domain,
                                       "TestApp",
                                       application_version=APP_V1)

        for i in range(3):
            module = self.app.add_module(
                Module.new_module("Module%d" % i, "en"))
            for j in range(3):
                self.app.new_form(module.id,
                                  name="Form%s-%s" % (i, j),
                                  attachment=self.xform_str,
                                  lang="en")
            module = self.app.get_module(i)
            detail = module.ref_details.short
            detail.columns.append(
                DetailColumn(header={"en": "test"},
                             model="case",
                             field="test",
                             format="plain"))
            detail.columns.append(
                DetailColumn(header={"en": "age"},
                             model="case",
                             field="age",
                             format="years-ago"))
        self.app.save()

        self.build1 = {'version': '1.2.dev', 'build_number': 7106}
        self.build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**self.build1)
        add_build(**self.build2)
Exemple #3
0
    def test_download_file_bad_xform_404(self, mock):
        '''
        This tests that the `download_file` view returns
        HTTP code 404 for XML that cannot be generated...
        in some sense it does not exist.
        '''

        module = self.app.add_module(Module.new_module("Module0", "en"))

        # These builds are checked in to the repo for use in tests
        build1 = {'version': '1.2.0', 'build_number': 7106}
        build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**build1)
        add_build(**build2)

        self.app.new_form(module.id, name="Form0-0", lang="en")
        self.app.save()

        mock.side_effect = XFormValidationError('')
        response = self.client.get(
            reverse('app_download_file',
                    kwargs=dict(domain=self.project.name,
                                app_id=self.app.get_id,
                                path='modules-0/forms-0.xml')))
        self.assertEqual(response.status_code, 404)
Exemple #4
0
    def test_download_file_bad_xform_404(self):
        '''
        This tests that the `download_file` view returns
        HTTP code 404 for XML that cannot be generated...
        in some sense it does not exist.
        '''

        module = self.app.add_module(Module.new_module("Module0", "en"))

        # These builds are checked in to the repo for use in tests
        build1 = {'version': '1.2.dev', 'build_number': 7106}
        build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**build1)
        add_build(**build2)

        with open(os.path.join(os.path.dirname(__file__), "data", "invalid_form.xml")) as f:
            xform_str = f.read()
        self.app.new_form(module.id, name="Form0-0", attachment=xform_str, lang="en")
        self.app.save()

        response = self.client.get(reverse('app_download_file', kwargs=dict(domain=self.domain.name,
                                                                            app_id=self.app.get_id,
                                                                            path='modules-0/forms-0.xml')))
        self.assertEqual(response.status_code, 404)
    def setUpClass(cls):
        cls.build1 = {'version': '1.2.dev', 'build_number': 7106}
        cls.build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**cls.build1)
        add_build(**cls.build2)

        cls.domain = 'test-domain'
        create_domain(cls.domain)
    def setUpClass(cls):
        cls.build1 = {"version": "1.2.dev", "build_number": 7106}
        cls.build2 = {"version": "2.7.0", "build_number": 20655}

        add_build(**cls.build1)
        add_build(**cls.build2)

        cls.domain = "test-domain"
        create_domain(cls.domain)

        with codecs.open(os.path.join(os.path.dirname(__file__), "data", "itext_form.xml"), encoding="utf-8") as f:
            cls.xform_str = f.read()
Exemple #7
0
    def setUpClass(cls):
        super(AppManagerTest, cls).setUpClass()
        cls.build1 = {'version': '1.2.0', 'build_number': 7106}
        cls.build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**cls.build1)
        add_build(**cls.build2)

        cls.domain = 'test-domain'
        create_domain(cls.domain)

        cls.xform_str = cls.get_xml('very_simple_form').decode('utf-8')
Exemple #8
0
    def setUpClass(cls):
        super(AppManagerTest, cls).setUpClass()
        cls.build1 = {'version': '1.2.dev', 'build_number': 7106}
        cls.build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**cls.build1)
        add_build(**cls.build2)

        cls.domain = 'test-domain'
        create_domain(cls.domain)

        with codecs.open(os.path.join(os.path.dirname(__file__), "data", "very_simple_form.xml"), encoding='utf-8') as f:
            cls.xform_str = f.read()
Exemple #9
0
    def setUpClass(cls):
        super(AppManagerTest, cls).setUpClass()
        cls.build1 = {'version': '1.2.dev', 'build_number': 7106}
        cls.build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**cls.build1)
        add_build(**cls.build2)

        cls.domain = 'test-domain'
        create_domain(cls.domain)

        with codecs.open(os.path.join(os.path.dirname(__file__), "data", "very_simple_form.xml"), encoding='utf-8') as f:
            cls.xform_str = f.read()
Exemple #10
0
 def setUpClass(cls):
     domain = 'apptest'
     cls.domain = Domain.get_or_create_with_name(domain, is_active=True)
     cls.cc_2_build = add_build(version='2.7.0', build_number=20655)
     with open(os.path.join(os.path.dirname(__file__), 'data', 'yesno.json')) as f:
         source = json.load(f)
     cls.app = Application.wrap(source)
     cls.app.domain = domain
     cls.app.save()
     cls.build = cls.app.make_build()
     cls.build.save(increment_version=False)
 def setUpClass(cls):
     super(TestViews, cls).setUpClass()
     cls.domain = Domain(name='app-manager-testviews-domain', is_active=True)
     cls.domain.save()
     cls.username = '******'
     cls.password = '******'
     cls.user = WebUser.create(cls.domain.name, cls.username, cls.password, is_active=True)
     cls.user.is_superuser = True
     cls.user.save()
     cls.build = add_build(version='2.7.0', build_number=20655)
     toggles.CUSTOM_PROPERTIES.set("domain:{domain}".format(domain=cls.domain.name), True)
Exemple #12
0
 def setUpClass(cls):
     cls.domain = Domain(name='app-manager-testviews-domain', is_active=True)
     cls.domain.save()
     cls.username = '******'
     cls.password = '******'
     cls.user = WebUser.create(cls.domain.name, cls.username, cls.password, is_active=True)
     cls.user.is_superuser = True
     cls.user.save()
     cls.build = add_build(version='2.7.0', build_number=20655)
     cls.app = Application.new_app(cls.domain.name, "TestApp", application_version=APP_V1)
     cls.app.build_spec = BuildSpec.from_string('2.7.0/latest')
     toggles.CUSTOM_PROPERTIES.set("domain:{domain}".format(domain=cls.domain.name), True)
Exemple #13
0
    def setUpClass(cls):
        super(TestViews, cls).setUpClass()
        cls.project = Domain(name='app-manager-testviews-domain', is_active=True)
        cls.project.save()
        cls.username = '******'
        cls.password = '******'
        cls.user = WebUser.create(cls.project.name, cls.username, cls.password, is_active=True)
        cls.user.is_superuser = True
        cls.user.save()
        cls.build = add_build(version='2.7.0', build_number=20655)
        cls.es = get_es_new()
        initialize_index_and_mapping(cls.es, APP_INDEX_INFO)

        toggles.CUSTOM_PROPERTIES.set("domain:{domain}".format(domain=cls.project.name), True)
    def setUpClass(cls):
        super(TestViews, cls).setUpClass()
        cls.project = Domain(name='app-manager-testviews-domain', is_active=True)
        cls.project.save()
        cls.username = '******'
        cls.password = '******'
        cls.user = WebUser.create(cls.project.name, cls.username, cls.password, is_active=True)
        cls.user.is_superuser = True
        cls.user.save()
        cls.build = add_build(version='2.7.0', build_number=20655)
        cls.es = get_es_new()
        initialize_index_and_mapping(cls.es, APP_INDEX_INFO)

        toggles.CUSTOM_PROPERTIES.set("domain:{domain}".format(domain=cls.project.name), True)
    def setUp(self):
        self.domain = 'test-domain'
        create_domain(self.domain)
        self.app = Application.new_app(self.domain, "TestApp", application_version=APP_V1)

        for i in range(3):
            module = self.app.add_module(Module.new_module("Module%d" % i, "en"))
            for j in range(3):
                self.app.new_form(module.id, name="Form%s-%s" % (i,j), attachment=self.xform_str, lang="en")
            module = self.app.get_module(i)
            detail = module.ref_details.short
            detail.columns.append(
                DetailColumn(header={"en": "test"}, model="case", field="test", format="plain")
            )
            detail.columns.append(
                DetailColumn(header={"en": "age"}, model="case", field="age", format="years-ago")
            )
        self.app.save()

        self.build1 = {'version': '1.2.dev', 'build_number': 7106}
        self.build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**self.build1)
        add_build(**self.build2)
Exemple #16
0
    def test_download_file_bad_xform_404(self, mock):
        '''
        This tests that the `download_file` view returns
        HTTP code 404 for XML that cannot be generated...
        in some sense it does not exist.
        '''

        module = self.app.add_module(Module.new_module("Module0", "en"))

        # These builds are checked in to the repo for use in tests
        build1 = {'version': '1.2.0', 'build_number': 7106}
        build2 = {'version': '2.7.0', 'build_number': 20655}

        add_build(**build1)
        add_build(**build2)

        self.app.new_form(module.id, name="Form0-0", lang="en")
        self.app.save()

        mock.side_effect = XFormValidationError('')
        response = self.client.get(reverse('app_download_file', kwargs=dict(domain=self.project.name,
                                                                            app_id=self.app.get_id,
                                                                            path='modules-0/forms-0.xml')))
        self.assertEqual(response.status_code, 404)
Exemple #17
0
 def setUpClass(cls):
     super(TestViews, cls).setUpClass()
     cls.project = Domain.get_or_create_with_name(
         'app-manager-testviews-domain', is_active=True)
     cls.username = '******'
     cls.password = '******'
     cls.user = WebUser.create(cls.project.name,
                               cls.username,
                               cls.password,
                               None,
                               None,
                               is_active=True)
     cls.user.is_superuser = True
     cls.user.save()
     cls.build = add_build(version='2.7.0', build_number=20655)
     cls.es = get_es_new()
     initialize_index_and_mapping(cls.es, APP_INDEX_INFO)
Exemple #18
0
 def setUpClass(cls):
     cls.domain = Domain(name='app-manager-testviews-domain',
                         is_active=True)
     cls.domain.save()
     cls.username = '******'
     cls.password = '******'
     cls.user = WebUser.create(cls.domain.name,
                               cls.username,
                               cls.password,
                               is_active=True)
     cls.user.is_superuser = True
     cls.user.save()
     cls.build = add_build(version='2.7.0', build_number=20655)
     cls.app = Application.new_app(cls.domain.name, "TestApp")
     cls.app.build_spec = BuildSpec.from_string('2.7.0/latest')
     toggles.CUSTOM_PROPERTIES.set(
         "domain:{domain}".format(domain=cls.domain.name), True)
    def test(self, mock):
        add_build(version='2.7.0', build_number=20655)
        domain = 'form-versioning-test'

        # set up inital app
        app = Application.new_app(domain, 'Foo')
        app.modules.append(Module(forms=[Form(), Form()]))
        app.build_spec = BuildSpec.from_string('2.7.0/latest')
        app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.0')
        app.get_module(0).get_form(1).source = BLANK_TEMPLATE.format(xmlns='xmlns-1')
        app.save()

        # make a build
        build1 = app.make_build()
        build1.save()

        # modify first form
        app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.1')
        app.save()

        # make second build
        build2 = app.make_build()
        build2.save()

        # modify first form
        app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.2')
        app.save()
        app.save()
        app.save()

        # make third build
        build3 = app.make_build()
        build3.save()

        self.assertEqual(self.get_form_versions(build1), [1, 1])
        self.assertEqual(self.get_form_versions(build2), [2, 1])
        self.assertEqual(self.get_form_versions(build3), [5, 1])

        # revert to build2
        app = app.make_reversion_to_copy(build2)
        app.save()

        # make reverted build
        build4 = app.make_build()
        build4.save()

        self.assertEqual(self.get_form_versions(build4), [6, 1])

        # copy app
        xxx_app = import_app(app.export_json(dump_json=False), domain)

        # make build of copy
        xxx_build1 = xxx_app.make_build()
        xxx_build1.save()

        # modify first form of copy app
        xxx_app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.xxx.0')
        xxx_app.save()

        # make second build of copy
        xxx_build2 = xxx_app.make_build()
        xxx_build2.save()

        self.assertEqual(self.get_form_versions(xxx_build1), [1, 1])
        self.assertEqual(self.get_form_versions(xxx_build2), [2, 1])
    def test(self, mock):
        add_build(version='2.7.0', build_number=20655)
        domain = 'form-versioning-test'

        # set up inital app
        factory = AppFactory(domain, 'Foo')
        m0, f0 = factory.new_basic_module("bar", "bar")
        f0.source = get_simple_form(xmlns='xmlns-0.0')
        f1 = factory.new_form(m0)
        f1.source = get_simple_form(xmlns='xmlns-1')
        app = factory.app
        app.build_spec = BuildSpec.from_string('2.7.0/latest')
        app.save()

        # make a build
        build1 = app.make_build()
        build1.save()

        # modify first form
        app.get_module(0).get_form(0).source = get_simple_form(
            xmlns='xmlns-0.1')
        app.save()

        # make second build
        build2 = app.make_build()
        build2.save()

        # modify first form
        app.get_module(0).get_form(0).source = get_simple_form(
            xmlns='xmlns-0.2')
        app.save()
        app.save()
        app.save()

        # make third build
        build3 = app.make_build()
        build3.save()

        self.assertEqual(self.get_form_versions(build1), [1, 1])
        self.assertEqual(self.get_form_versions(build2), [2, 1])
        self.assertEqual(self.get_form_versions(build3), [5, 1])

        # revert to build2
        app = app.make_reversion_to_copy(build2)
        app.save()

        # make reverted build
        build4 = app.make_build()
        build4.save()

        self.assertEqual(self.get_form_versions(build4), [6, 1])

        # copy app
        xxx_app = import_app(app.export_json(dump_json=False), domain)

        # make build of copy
        xxx_build1 = xxx_app.make_build()
        xxx_build1.save()

        # modify first form of copy app
        xxx_app.get_module(0).get_form(0).source = get_simple_form(
            xmlns='xmlns-0.xxx.0')
        xxx_app.save()

        # make second build of copy
        xxx_build2 = xxx_app.make_build()
        xxx_build2.save()

        self.assertEqual(self.get_form_versions(xxx_build1), [1, 1])
        self.assertEqual(self.get_form_versions(xxx_build2), [2, 1])
Exemple #21
0
    def test(self, mock):
        add_build(version='2.7.0', build_number=20655)
        domain = 'form-versioning-test'

        # set up inital app
        app = Application.new_app(domain, 'Foo')
        app.modules.append(Module(forms=[Form(), Form()]))
        app.build_spec = BuildSpec.from_string('2.7.0/latest')
        app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(
            xmlns='xmlns-0.0')
        app.get_module(0).get_form(1).source = BLANK_TEMPLATE.format(
            xmlns='xmlns-1')
        app.save()

        # make a build
        build1 = app.make_build()
        build1.save()

        # modify first form
        app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(
            xmlns='xmlns-0.1')
        app.save()

        # make second build
        build2 = app.make_build()
        build2.save()

        # modify first form
        app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(
            xmlns='xmlns-0.2')
        app.save()
        app.save()
        app.save()

        # make third build
        build3 = app.make_build()
        build3.save()

        self.assertEqual(self.get_form_versions(build1), [1, 1])
        self.assertEqual(self.get_form_versions(build2), [2, 1])
        self.assertEqual(self.get_form_versions(build3), [5, 1])

        # revert to build2
        app = app.make_reversion_to_copy(build2)
        app.save()

        # make reverted build
        build4 = app.make_build()
        build4.save()

        self.assertEqual(self.get_form_versions(build4), [6, 1])

        # copy app
        xxx_app = import_app(app.export_json(dump_json=False), domain)

        # make build of copy
        xxx_build1 = xxx_app.make_build()
        xxx_build1.save()

        # modify first form of copy app
        xxx_app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(
            xmlns='xmlns-0.xxx.0')
        xxx_app.save()

        # make second build of copy
        xxx_build2 = xxx_app.make_build()
        xxx_build2.save()

        self.assertEqual(self.get_form_versions(xxx_build1), [1, 1])
        self.assertEqual(self.get_form_versions(xxx_build2), [2, 1])