Beispiel #1
0
    def test_change_question_sets_contains_changes(self):
        self._add_question(self.app1.modules[0].forms[0], {'constraint': 'foo = bar'})
        self._add_question(self.app2.modules[0].forms[0], {'constraint': 'foo != bar'})
        first, second = get_app_diff(self.app1, self.app2)

        self.assertTrue(first[0]['forms'][0].changes.contains_changes)
        self.assertTrue(second[0]['forms'][0].changes.contains_changes)
Beispiel #2
0
 def test_change_form_name(self):
     self.app2.modules[0].forms[0].name['en'] = "a new name"
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][0]['changes']['name']['type'],
                      CHANGED)
     self.assertEqual(first[0]['forms'][0]['changes']['name']['type'],
                      CHANGED)
Beispiel #3
0
    def test_change_question_sets_contains_changes(self):
        self._add_question(self.app1.modules[0].forms[0], {'constraint': 'foo = bar'})
        self._add_question(self.app2.modules[0].forms[0], {'constraint': 'foo != bar'})
        first, second = get_app_diff(self.app1, self.app2)

        self.assertTrue(first[0]['forms'][0].changes.contains_changes)
        self.assertTrue(second[0]['forms'][0].changes.contains_changes)
Beispiel #4
0
 def test_add_form(self):
     self.factory2.new_form(self.app2.modules[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(second[0]['forms'][1]['changes']['form']['type'],
                      ADDED)
     self.assertEqual(second[0]['forms'][1]['name'],
                      self.app2.modules[0].forms[1].name)
Beispiel #5
0
 def test_change_form_filter(self):
     self.app2.modules[0].forms[0].form_filter = "foo = 'bar'"
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(
         first[0]['forms'][0]['changes']['form_filter']['type'], CHANGED)
     self.assertEqual(
         first[0]['forms'][0]['changes']['form_filter']['type'], CHANGED)
Beispiel #6
0
 def test_remove_then_add_module(self):
     self.factory1.new_basic_module('module_2', 'case')
     self.factory2.new_basic_module('module_3', 'case')
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[1]['changes']['module']['type'], REMOVED)
     self.assertEqual(first[1]['unique_id'], self.app1.modules[1].unique_id)
     self.assertEqual(second[1]['changes']['module']['type'], ADDED)
     self.assertEqual(second[1]['unique_id'], self.app2.modules[1].unique_id)
Beispiel #7
0
 def test_remove_then_add_module(self):
     self.factory1.new_basic_module('module_2', 'case')
     self.factory2.new_basic_module('module_3', 'case')
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[1]['changes']['module'], REMOVED)
     self.assertEqual(first[1]['unique_id'], self.app1.modules[1].unique_id)
     self.assertEqual(second[1]['changes']['module'], ADDED)
     self.assertEqual(second[1]['unique_id'], self.app2.modules[1].unique_id)
Beispiel #8
0
 def test_remove_question_from_group(self):
     self._add_question_to_group(self.app1.modules[0].forms[0], {
         'name': 'question_in_group',
         'label': 'Q in a group',
         'group': 'agroup',
     })
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][0]['questions'][0]['children'][0]['changes']['question'], REMOVED)
Beispiel #9
0
 def test_add_question_constraint(self):
     self._add_question(self.app1.modules[0].forms[0], {'constraint': ''})
     self._add_question(self.app2.modules[0].forms[0],
                        {'constraint': 'foo = bar'})
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(
         second[0]['forms'][0]['questions'][0]['changes']['constraint']
         ['type'], ADDED)
Beispiel #10
0
 def test_add_question_translation(self):
     self.app1.langs = ['en', 'it']
     self.app2.langs = ['en', 'it']
     self._add_question(self.app1.modules[0].forms[0], {'label': {'en': 'food'}})
     self._add_question(self.app2.modules[0].forms[0], {'label': {'en': 'food', 'it': 'cibo'}})
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][0]['questions'][0]['changes']['translations']['type'], CHANGED)
     self.assertEqual(second[0]['forms'][0]['questions'][0]['changes']['translations']['type'], CHANGED)
Beispiel #11
0
 def test_change_question_label(self):
     self._add_question(self.app1.modules[0].forms[0], {'label': 'foo'})
     self._add_question(self.app2.modules[0].forms[0], {'label': 'bar'})
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(
         first[0]['forms'][0]['questions'][0]['changes']['label']['type'],
         CHANGED)
     self.assertEqual(
         second[0]['forms'][0]['questions'][0]['changes']['label']['type'],
         CHANGED)
Beispiel #12
0
    def test_remove_save_property(self):
        self._add_question(self.app1.modules[0].forms[0])
        self._add_question(self.app2.modules[0].forms[0])
        self.factory1.form_requires_case(self.app1.modules[0].forms[0], update={'foo': '/data/name'})
        self.app1.save()

        first, second = get_app_diff(self.app1, self.app2)
        self.assertEqual(
            first[0]['forms'][0]['questions'][0]['changes']['save_properties']['case']['foo'],
            REMOVED
        )
Beispiel #13
0
 def test_remove_question_from_group(self):
     self._add_question_to_group(
         self.app1.modules[0].forms[0], {
             'name': 'question_in_group',
             'label': 'Q in a group',
             'group': 'agroup',
         })
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(
         first[0]['forms'][0]['questions'][0]['children'][0]['changes']
         ['question']['type'], REMOVED)
Beispiel #14
0
    def test_remove_save_property(self):
        self._add_question(self.app1.modules[0].forms[0])
        self._add_question(self.app2.modules[0].forms[0])
        self.factory1.form_requires_case(self.app1.modules[0].forms[0],
                                         update={'foo': '/data/name'})
        self.app1.save()

        first, second = get_app_diff(self.app1, self.app2)
        self.assertEqual(
            first[0]['forms'][0]['questions'][0]['changes']['save_properties']
            ['case']['foo']['type'], REMOVED)
Beispiel #15
0
 def test_change_question_in_group(self):
     self._add_question_to_group(self.app1.modules[0].forms[0], {
         'name': 'question_in_group',
         'label': 'Q in a group',
         'group': 'agroup',
     })
     self._add_question_to_group(self.app2.modules[0].forms[0], {
         'name': 'question_in_group',
         'label': 'Foo in a group',
         'group': 'agroup'
     })
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(second[0]['forms'][0]['questions'][0]['children'][0]['changes']['label'], CHANGED)
Beispiel #16
0
 def test_change_question_in_group(self):
     self._add_question_to_group(self.app1.modules[0].forms[0], {
         'name': 'question_in_group',
         'label': 'Q in a group',
         'group': 'agroup',
     })
     self._add_question_to_group(self.app2.modules[0].forms[0], {
         'name': 'question_in_group',
         'label': 'Foo in a group',
         'group': 'agroup'
     })
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(second[0]['forms'][0]['questions'][0]['children'][0]['changes']['label']['type'], CHANGED)
Beispiel #17
0
 def test_remove_then_add_question(self):
     self._add_question(self.app1.modules[0].forms[0], {
         'name': 'foo',
         'label': 'foo'
     })
     self._add_question(self.app2.modules[0].forms[0], {
         'name': 'bar',
         'label': 'bar'
     })
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(
         first[0]['forms'][0]['questions'][0]['changes']['question']
         ['type'], REMOVED)
     self.assertEqual(
         second[0]['forms'][0]['questions'][0]['changes']['question']
         ['type'], ADDED)
Beispiel #18
0
    def test_move_form(self):
        # A moved form should show up as deleted and re-added
        self.factory1.new_form(self.app1.modules[0])
        self.factory1.new_basic_module('module_2', 'case')
        self.factory2.new_form(self.app2.modules[0])
        self.factory2.new_basic_module('module_2', 'case')

        self.app2.rearrange_forms(
            from_module_uid=self.app2.modules[0].unique_id,
            to_module_uid=self.app2.modules[1].unique_id,
            from_index=1,
            to_index=1,
        )

        first, second = get_app_diff(self.app1, self.app2)
        self.assertEqual(first[0]['forms'][1]['changes']['form']['type'], REMOVED)
        self.assertEqual(second[1]['forms'][1]['changes']['form']['type'], ADDED)
Beispiel #19
0
    def page_context(self):
        context = super(FormSummaryDiffView, self).page_context

        if self.first_app.master_id != self.second_app.master_id:
            # This restriction is somewhat arbitrary, as you might want to
            # compare versions between two different apps on the same domain.
            # However, it breaks a bunch of assumptions in the UI
            raise Http404()

        first = self._app_dict(self.first_app)
        second = self._app_dict(self.second_app)

        first['modules'], second['modules'] = get_app_diff(self.first_app, self.second_app)

        context.update({
            'page_type': 'form_diff',
            'app_id': self.app.master_id,
            'first': first,
            'second': second,
        })
        return context
Beispiel #20
0
    def test_change_save_property(self):
        self._add_question(self.app1.modules[0].forms[0])
        self._add_question(self.app2.modules[0].forms[0])
        self.factory1.form_requires_case(self.app1.modules[0].forms[0],
                                         update={"foo": "/data/name"})
        self.factory2.form_requires_case(self.app2.modules[0].forms[0],
                                         update={"bar": "/data/name"})
        self.app1.save()
        self.app2.save()

        first, second = get_app_diff(self.app1, self.app2)
        self.assertEqual(
            first[0]['forms'][0]['questions'][0]['changes']['save_properties']
            ['case']['foo']['type'],
            REMOVED,
        )
        self.assertEqual(
            second[0]['forms'][0]['questions'][0]['changes']['save_properties']
            ['case']['bar']['type'],
            ADDED,
        )
Beispiel #21
0
 def test_add_question(self):
     self._add_question(self.app2.modules[0].forms[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(second[0]['forms'][0]['questions'][0]['changes']['question'], ADDED)
Beispiel #22
0
 def test_change_question_constraint(self):
     self._add_question(self.app1.modules[0].forms[0], {'constraint': 'foo = bar'})
     self._add_question(self.app2.modules[0].forms[0], {'constraint': 'foo != bar'})
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][0]['questions'][0]['changes']['constraint'], CHANGED)
     self.assertEqual(second[0]['forms'][0]['questions'][0]['changes']['constraint'], CHANGED)
Beispiel #23
0
 def test_remove_form_sets_contains_changes(self):
     self.factory1.new_form(self.app1.modules[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertTrue(first[0]['forms'][1].changes.contains_changes)
Beispiel #24
0
 def test_remove_form_sets_contains_changes(self):
     self.factory1.new_form(self.app1.modules[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertTrue(first[0]['forms'][1].changes.contains_changes)
Beispiel #25
0
 def test_add_form(self):
     self.factory2.new_form(self.app2.modules[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(second[0]['forms'][1]['changes']['form'], ADDED)
     self.assertEqual(second[0]['forms'][1]['name'], self.app2.modules[0].forms[1].name)
Beispiel #26
0
 def test_remove_question(self):
     self._add_question(self.app1.modules[0].forms[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(
         first[0]['forms'][0]['questions'][0]['changes']['question']
         ['type'], REMOVED)
Beispiel #27
0
 def test_add_question(self):
     self._add_question(self.app2.modules[0].forms[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(
         second[0]['forms'][0]['questions'][0]['changes']['question']
         ['type'], ADDED)
Beispiel #28
0
 def test_remove_form(self):
     self.factory1.new_form(self.app1.modules[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][1]['changes']['form']['type'],
                      REMOVED)
Beispiel #29
0
 def test_change_form_name(self):
     self.app2.modules[0].forms[0].name['en'] = "a new name"
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][0]['changes']['name'], CHANGED)
     self.assertEqual(first[0]['forms'][0]['changes']['name'], CHANGED)
Beispiel #30
0
 def test_change_form_filter(self):
     self.app2.modules[0].forms[0].form_filter = "foo = 'bar'"
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][0]['changes']['form_filter'], CHANGED)
     self.assertEqual(first[0]['forms'][0]['changes']['form_filter'], CHANGED)
Beispiel #31
0
 def test_remove_then_add_question(self):
     self._add_question(self.app1.modules[0].forms[0], {'name': 'foo', 'label': 'foo'})
     self._add_question(self.app2.modules[0].forms[0], {'name': 'bar', 'label': 'bar'})
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][0]['questions'][0]['changes']['question'], REMOVED)
     self.assertEqual(second[0]['forms'][0]['questions'][0]['changes']['question'], ADDED)
Beispiel #32
0
 def test_remove_form(self):
     self.factory1.new_form(self.app1.modules[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][1]['changes']['form'], REMOVED)
Beispiel #33
0
 def test_remove_question(self):
     self._add_question(self.app1.modules[0].forms[0])
     first, second = get_app_diff(self.app1, self.app2)
     self.assertEqual(first[0]['forms'][0]['questions'][0]['changes']['question'], REMOVED)