Esempio n. 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.
        '''

        app = Application.new_app(self.domain, "TestApp", application_version=APP_V1)
        module = 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()
        app.new_form(module.id, name="Form0-0", attachment=xform_str, lang="en")
        app.save()

        response = self.client.get(reverse('app_download_file', kwargs=dict(domain=self.domain,
                                                                            app_id=app.get_id,
                                                                            path='modules-0/forms-0.xml')))
        self.assertEqual(response.status_code, 404)
 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)
Esempio n. 3
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)
Esempio n. 4
0
 def setUp(self):
     domain = 'apptest'
     self.domain = Domain.get_or_create_with_name(domain, is_active=True)
     self.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)
     self.app = Application.wrap(source)
     self.app.domain = domain
     self.app.save()
     self.build = self.app.make_build()
     self.build.save(increment_version=False)
    def test(self):
        add_build(version='2.7.0', build_number=20655)
        domain = 'form-versioning-test'

        # set up inital app
        app = Application.new_app(domain, 'Foo', '2.0')
        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(previous_version=None)
        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(previous_version=build1)
        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(previous_version=build2)
        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(previous_version=build3)
        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(previous_version=None)
        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(previous_version=xxx_build1)
        xxx_build2.save()

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