def testDateTimeSinceColumn(self): """Testing DateTimeSinceColumn""" class DummyObj: time = None column = DateTimeSinceColumn("Test", field_name='time') now = datetime.now() obj = DummyObj() obj.time = now self.assertEqual(column.render_data(obj), "0 minutes ago") obj.time = now - timedelta(days=5) self.assertEqual(column.render_data(obj), "5 days ago") obj.time = now - timedelta(days=7) self.assertEqual(column.render_data(obj), "1 week ago")
def testDateTimeSinceColumn(self): """Testing DateTimeSinceColumn""" class DummyObj: time = None column = DateTimeSinceColumn("Test", field_name='time') now = datetime.now() obj = DummyObj() obj.time = now self.assertEqual(column.render_data(obj), "0 minutes ago") obj.time = now - timedelta(days=5) self.assertEqual(column.render_data(obj), "5 days ago") obj.time = now - timedelta(days=7) self.assertEqual(column.render_data(obj), "1 week ago")
def testDateTimeSinceColumn(self): """Testing DateTimeSinceColumn""" class DummyObj: time = None column = DateTimeSinceColumn("Test", field_name='time') if settings.USE_TZ: now = get_tz_aware_utcnow() else: now = datetime.now() obj = DummyObj() obj.time = now self.assertEqual(column.render_data(obj), "0\xa0minutes ago") obj.time = now - timedelta(days=5) self.assertEqual(column.render_data(obj), "5\xa0days ago") obj.time = now - timedelta(days=7) self.assertEqual(column.render_data(obj), "1\xa0week ago")
def testDateTimeSinceColumn(self): """Testing DateTimeSinceColumn""" class DummyObj: time = None column = DateTimeSinceColumn("Test", field_name='time') state = StatefulColumn(None, column) if settings.USE_TZ: now = get_tz_aware_utcnow() else: now = datetime.now() obj = DummyObj() obj.time = now self.assertEqual(column.render_data(state, obj), "0\xa0minutes ago") obj.time = now - timedelta(days=5) self.assertEqual(column.render_data(state, obj), "5\xa0days ago") obj.time = now - timedelta(days=7) self.assertEqual(column.render_data(state, obj), "1\xa0week ago")
def test_render_data(self): """Testing DateTimeSinceColumn.render_data""" class DummyObj: time = None column = DateTimeSinceColumn('Test', field_name='time') state = StatefulColumn(None, column) if settings.USE_TZ: now = get_tz_aware_utcnow() else: now = datetime.now() obj = DummyObj() obj.time = now self.assertEqual(column.render_data(state, obj), '0\xa0minutes ago') obj.time = now - timedelta(days=5) self.assertEqual(column.render_data(state, obj), '5\xa0days ago') obj.time = now - timedelta(days=7) self.assertEqual(column.render_data(state, obj), '1\xa0week ago')
def render_data(self, obj): if obj.diffset_history.last_diff_updated: return DateTimeSinceColumn.render_data(self, obj.diffset_history) else: return ""