Пример #1
0
 def test_basic(self):
     D = datetime.datetime
     model_count = PolicyModel.objects.all().count()
     url = urlreverse('celerymanagementapp.dataviews.policy_get', 
                      kwargs={'id': 1} )
     
     expected_output = {
         'success': True,
         'record': {
             'id': 1, 
             'name': 'normal_policy', 
             'source': 'policy:\n    schedule:\n        crontab()\n    apply:\n        True', 
             'enabled': True, 
             'modified': timeutil.datetime_from_python(D(2010,1,4,hour=12)), 
             'last_run_time': timeutil.datetime_from_python(D(2010,1,4,hour=12)),
             },
         'error_info': {
             'compile_error': False, 
             'type': '', 
             'msg': '', 
             'traceback': '',
             },
         }
     with self.scoped_login('test_user','password'):
         response = self.client.post(url, '', content_type='application/json')
     output = json.loads(response.content)
     
     self.assertEquals(expected_output, output)
     self.assertEquals(model_count, PolicyModel.objects.all().count())
Пример #2
0
 def make_row(obj):
     return {
         'id': obj.id, 
         'name': obj.name, 
         'enabled': obj.enabled, 
         'modified': (obj.modified and 
                     timeutil.datetime_from_python(obj.modified)), 
         'last_run_time': (obj.last_run_time and 
                     timeutil.datetime_from_python(obj.last_run_time)),
         }
Пример #3
0
 def make_record(self, model):
     # Used by derived classes.
     return {
         'id': model.id,
         'name': model.name,
         'source': model.source,
         'enabled': model.enabled,
         'modified': (model.modified and 
                     timeutil.datetime_from_python(model.modified)),
         'last_run_time': (model.last_run_time and 
                     timeutil.datetime_from_python(model.last_run_time)),
         }
Пример #4
0
 def test_basic(self):
     D = datetime.datetime
     url = urlreverse('celerymanagementapp.dataviews.policy_list')
     
     modified = timeutil.datetime_from_python(D(2010,1,4,hour=12))
     last_run_time = timeutil.datetime_from_python(D(2010,1,4,hour=12))
             
     expected_output = [
         {'id': 1, 'name': 'normal_policy', 'enabled': True, 'modified': modified, 'last_run_time': last_run_time,},
         {'id': 2, 'name': 'second_policy', 'enabled': True, 'modified': modified, 'last_run_time': last_run_time,},
     ]
         
     with self.scoped_login('test_user','password'):
         response = self.client.post(url, '', content_type='application/json')
     output = json.loads(response.content)
     
     self.assertEquals(expected_output, output)
Пример #5
0
 def test_datetime_from_python2(self):
     from celerymanagementapp.timeutil import datetime_from_python
     tz = self.tz_offset()*1000
     D = datetime.datetime
     self.assertEquals(946684800000+tz, datetime_from_python(D(2000,1,1)))
Пример #6
0
 def test_datetime_from_python(self):
     from celerymanagementapp.timeutil import datetime_from_python
     now = datetime.datetime.now()
     ms = int(time.mktime(now.timetuple())*1000 + now.microsecond/1000)
     
     self.assertEquals(ms, datetime_from_python(now))