예제 #1
0
    def test_update_expiry_field(self):
        category = CategoryFactory()
        field = DateTimeFieldFactory(**{
            'key': 'expires_at',
            'category': category
        })
        category.expiry_field = field
        category.save()

        observation = ObservationFactory(
            **{
                'project': category.project,
                'category': category,
                'expiry_field': None,
                'properties': {
                    'expires_at': '2016-09-19T15:51:32.804Z'
                }
            })

        observation.update_expiry_field()
        observation.save()

        ref = Observation.objects.get(pk=observation.id)
        self.assertEqual(
            ref.expiry_field,
            datetime.datetime(2016, 9, 19, 15, 51, 32, 804000,
                              tzinfo=pytz.utc))
예제 #2
0
    def test_update_expiry_field(self):
        category = CategoryFactory()
        field = DateTimeFieldFactory(**{
            'key': 'expires_at',
            'category': category
        })
        category.expiry_field = field
        category.save()

        observation = ObservationFactory(**{
            'project': category.project,
            'category': category,
            'expiry_field': None,
            'properties': {
                'expires_at': '2016-09-19T15:51:32.804Z'
            }
        })

        observation.update_expiry_field()
        observation.save()

        ref = Observation.objects.get(pk=observation.id)
        self.assertEqual(
            ref.expiry_field,
            datetime.datetime(2016, 9, 19, 15, 51, 32, 804000, tzinfo=pytz.utc)
        )
예제 #3
0
    def test_update_expiry_field_empty_properties(self):
        category = CategoryFactory()
        field = DateTimeFieldFactory(**{
            'key': 'expires_at',
            'category': category
        })
        category.expiry_field = field
        category.save()

        observation = ObservationFactory(**{
            'project': category.project,
            'category': category,
            'expiry_field': None,
            'properties': {}
        })

        observation.update_expiry_field()
        observation.save()

        ref = Observation.objects.get(pk=observation.id)
        self.assertEqual(ref.expiry_field, None)
예제 #4
0
    def test_update_expiry_field_empty_properties(self):
        category = CategoryFactory()
        field = DateTimeFieldFactory(**{
            'key': 'expires_at',
            'category': category
        })
        category.expiry_field = field
        category.save()

        observation = ObservationFactory(**{
            'project': category.project,
            'category': category,
            'expiry_field': None,
            'properties': None
        })

        observation.update_expiry_field()
        observation.save()

        ref = Observation.objects.get(pk=observation.id)
        self.assertEqual(ref.expiry_field, None)