def test_delete_older_than_x_invalid_unit_time_from_topic(self): with test_database(test_db, (Log, Topic), create_tables=True): self.msg.topic = Settings.ROOT_TOPIC + '/delete/years' Log.create(timestamp=datetime.now() - timedelta(days=30), value="12", topic='/test/topic') Log.create(timestamp=datetime.now() - timedelta(days=20), value="12", topic='/test/topic') Log.create(timestamp=datetime.now() - timedelta(days=10), value="12", topic='/test/topic') logs = LogController() query_result = logs.delete_topic_entries(self.msg) dic_result = json.loads(query_result) self.assertEqual('KO', dic_result['result'])
def test_delete_older_than_x_days_from_topic(self): with test_database(test_db, (Log, Topic), create_tables=True): self.msg.topic = Settings.ROOT_TOPIC + '/delete/days' Log.create(timestamp=datetime.now() - timedelta(days=30), value="12", topic='/test/topic') Log.create(timestamp=datetime.now() - timedelta(days=20), value="12", topic='/test/topic') Log.create(timestamp=datetime.now() - timedelta(days=10), value="12", topic='/test/topic') logs = LogController() query_result = logs.delete_topic_entries(self.msg) dic_result = json.loads(query_result) self.assertEqual(1, dic_result['values']) data_after_delete = Log.select() self.assertEqual(2, data_after_delete.count())