Esempio n. 1
0
    def test_interval_has_schedule(self):
        """Interval schedule property is valid."""
        i = Interval()
        i.period = 'days'
        i.every = 7

        self.assertIsInstance(i.schedule, celery.schedules.schedule)
Esempio n. 2
0
    def test_interval_serializing(self):
        """Correct serialization."""
        i = Interval()
        i.period = 'days'
        i.every = 7

        self.assertEqual(i.to_dict(), {'every': 7, 'period': 'days'})
Esempio n. 3
0
    def test_interval_correct_every_init(self):
        """Using getter with correct data set."""
        i = Interval()

        i.every = '7'
        self.assertEqual(i.every, 7)

        i.every = 7
        self.assertEqual(i.every, 7)
Esempio n. 4
0
    def test_interval_deserializing(self):
        """Correct deserialization."""
        data = {'every': 7, 'period': 'days'}

        i = Interval.from_dict(data)
        self.assertEqual(i.period, 'days')
        self.assertEqual(i.every, 7)
Esempio n. 5
0
    def test_interval_get_period_no_data(self):
        """Using getter with no data set."""
        i = Interval()

        self.assertRaisesRegexp(ValueError,
                                "'period' attribute cannot be None.", getattr,
                                i, 'period')
Esempio n. 6
0
    def test_interval_set_every_bad_data(self):
        """Exception when initializing with bad data."""
        i = Interval()

        self.assertRaisesRegexp(ValueError,
                                "Value must be a positive integer.", setattr,
                                i, 'every', -12)
        self.assertRaisesRegexp(ValueError,
                                "Value must be a positive integer.", setattr,
                                i, 'every', 'something')
Esempio n. 7
0
    def test_interval_deserializing_no_data(self):
        """No data when deserializing."""
        i = Interval.from_dict(None)

        self.assertIsNone(i)
Esempio n. 8
0
    def test_interval_set_every_no_data(self):
        """Every is set to zero."""
        i = Interval()

        i.every = None
        self.assertEqual(i.every, 0)
Esempio n. 9
0
    def test_interval_set_period_bad_data(self):
        """Exception when initializing with bad data."""
        i = Interval()

        self.assertRaises(ValueError, setattr, i, 'period', 'something')
Esempio n. 10
0
    def test_interval_correct_period_init(self):
        """Using getter with correct data set."""
        i = Interval()
        i.period = 'days'

        self.assertEqual(i.period, 'days')