예제 #1
0
    def test_get_updated_data(self):
        user = UserF.create()
        project = ProjectF.create(add_admins=[user])
        category_1 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'text',
            'category': category_1
        })

        observation = ObservationFactory.create(**{
            'project': project,
            'category': category_1,
            'properties': {'text': 'yes to update'}
        })

        for x in range(0, 5):
            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'yes ' + str(x)}
            })

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'no ' + str(x)}
            })

        view = GroupingFactory(**{'project': project})
        RuleFactory(**{
            'grouping': view,
            'category': category_1,
            'constraints': {'text': 'yes'}
        })

        updater = UserF()
        update = {'text': 'yes, this has been updated', 'version': 1}
        observation.update(properties=update, updator=updater)
        self.assertEqual(view.data(user).count(), 6)