Ejemplo n.º 1
0
 def test_create_observation_active_default(self):
     creator = UserFactory()
     location = LocationFactory()
     category = CategoryFactory(**{
         'default_status': 'active'
     })
     TextFieldFactory(**{
         'key': 'text',
         'category': category,
         'order': 0
     })
     NumericFieldFactory(**{
         'key': 'number',
         'category': category,
         'order': 1
     })
     data = {'text': 'Text', 'number': 12}
     observation = Observation.create(
         properties=data, creator=creator, location=location,
         category=category, project=category.project, status='active'
     )
     self.assertEqual(observation.properties, data)
Ejemplo n.º 2
0
 def test_create_observation_with_polish_chars(self):
     creator = UserFactory()
     location = LocationFactory()
     category = CategoryFactory()
     TextFieldFactory(**{
         'key': 'text',
         'category': category,
         'required': True,
         'order': 0
     })
     NumericFieldFactory(**{
         'key': 'number',
         'category': category,
         'order': 1
     })
     data = {'text': u'śmietnik', 'number': 12}
     observation = Observation.create(properties=data,
                                      creator=creator,
                                      location=location,
                                      category=category,
                                      project=category.project,
                                      status='active')
     self.assertEqual(observation.properties, data)
Ejemplo n.º 3
0
    def test_validate_full_with_inactive_field(self):
        category = CategoryFactory()
        TextFieldFactory(**{'key': 'text', 'category': category, 'order': 0})
        TextFieldFactory(
            **{
                'key': 'inactive_text',
                'category': category,
                'status': 'inactive',
                'required': True,
                'order': 1
            })
        NumericFieldFactory(**{
            'key': 'number',
            'category': category,
            'order': 2
        })

        observation = ObservationFactory.create(
            **{
                'properties': {
                    'text': 'Text',
                    'number': 12
                },
                'category': category,
                'project': category.project
            })

        updater = UserFactory()
        update = {'text': 'Udpated Text', 'number': 13}
        Observation.validate_full(category=category, data=update)
        observation.update(properties=update, updator=updater)

        self.assertEqual(observation.properties, {
            'text': 'Udpated Text',
            'number': 13
        })
        self.assertEqual(observation.version, 2)