コード例 #1
0
    def test_validate_full_invalid(self):
        creator = UserFactory()
        location = LocationFactory()
        category = CategoryFactory()
        TextFieldFactory.create(**{
            'key': 'text',
            'category': category,
            'order': 0
        })
        NumericFieldFactory.create(**{
            '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')

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

        self.assertEqual(observation.properties, data)
        self.assertEqual(observation.version, 1)
コード例 #2
0
ファイル: test_model.py プロジェクト: nagyistoce/geokey
    def test_validate_full_invalid(self):
        creator = UserF()
        location = LocationFactory()
        category = CategoryFactory()
        TextFieldFactory.create(**{
            'key': 'text',
            'category': category,
            'order': 0
        })
        NumericFieldFactory.create(**{
            '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'
        )

        updater = UserF()
        update = {'text': 'Udpated Text', 'number': 'abc', 'version': 1}
        Observation.validate_full(category=category, data=update)
        observation.update(properties=update, updator=updater)

        self.assertEqual(observation.properties, data)
        self.assertEqual(observation.version, 1)
コード例 #3
0
 def test_validate_full_invalid_nubmer(self):
     category = CategoryFactory()
     TextFieldFactory(**{'key': 'text', 'category': category, 'order': 0})
     NumericFieldFactory(**{
         'key': 'number',
         'category': category,
         'order': 1
     })
     data = {'text': 'Text', 'number': 'abc'}
     Observation.validate_full(data=data, category=category)
コード例 #4
0
 def test_validate_full_with_empty_number(self):
     category = CategoryFactory()
     TextFieldFactory(**{'key': 'text', 'category': category, 'order': 0})
     NumericFieldFactory(**{
         'key': 'number',
         'required': True,
         'category': category,
         'order': 1
     })
     data = {'text': 'bla'}
     Observation.validate_full(data=data, category=category)
コード例 #5
0
ファイル: test_model.py プロジェクト: nagyistoce/geokey
 def test_validate_full_invalid_nubmer(self):
     category = CategoryFactory()
     TextFieldFactory(**{
         'key': 'text',
         'category': category,
         'order': 0
     })
     NumericFieldFactory(**{
         'key': 'number',
         'category': category,
         'order': 1
     })
     data = {'text': 'Text', 'number': 'abc'}
     Observation.validate_full(data=data, category=category)
コード例 #6
0
ファイル: test_model.py プロジェクト: nagyistoce/geokey
 def test_validate_full_with_empty_number(self):
     category = CategoryFactory()
     TextFieldFactory(**{
         'key': 'text',
         'category': category,
         'order': 0
     })
     NumericFieldFactory(**{
         'key': 'number',
         'required': True,
         'category': category,
         'order': 1
     })
     data = {'text': 'bla'}
     Observation.validate_full(data=data, category=category)
コード例 #7
0
 def test_validate_full_inactive_field(self):
     category = CategoryFactory()
     TextFieldFactory(**{'key': 'text', 'category': category, 'order': 2})
     TextFieldFactory(
         **{
             'key': 'inactive_text',
             'category': category,
             'status': 'inactive',
             'required': True,
             'order': 0
         })
     NumericFieldFactory(**{
         'key': 'number',
         'category': category,
         'order': 1
     })
     data = {'text': 'Text', 'number': 12}
     Observation.validate_full(category=category, data=data)
コード例 #8
0
ファイル: test_model.py プロジェクト: nagyistoce/geokey
 def test_validate_full_inactive_field(self):
     category = CategoryFactory()
     TextFieldFactory(**{
         'key': 'text',
         'category': category,
         'order': 2
     })
     TextFieldFactory(**{
         'key': 'inactive_text',
         'category': category,
         'status': 'inactive',
         'required': True,
         'order': 0
     })
     NumericFieldFactory(**{
         'key': 'number',
         'category': category,
         'order': 1
     })
     data = {'text': 'Text', 'number': 12}
     Observation.validate_full(category=category, data=data)
コード例 #9
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)
コード例 #10
0
ファイル: test_model.py プロジェクト: nagyistoce/geokey
    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 = UserF()
        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)