def test_no_log_on_creation(self): item = Item('fireflash') db_session.add(item) db_session.rollback() logs = Log.find_all() assert len(logs) == 0
def test_log_on_item_insert(self): item = Item('fireflash') db_session.add(item) db_session.commit() logs = Log.find_all() assert len(logs) == 1 assert logs[0].name == 'fireflash'
def test_log_on_variable(self): item = Item('fireflash') item.set_variable('hello', 'world') db_session.add(item) db_session.commit() logs = Log.find_all() assert len(logs) == 2 assert 'hello' in logs[0].message or 'hello' in logs[1].message
def test_log_order(self): now = datetime.utcnow() earlier = now - timedelta(1) log2 = Log('firefly', 'test2', earlier) log1 = Log('fireflash', 'test1', now) db_session.add(log1) db_session.add(log2) db_session.commit() logs = Log.find_all() assert logs[0].message == 'test1'
def show_log(): end = request.args.get('log-end') if end: end = datetime.strptime(end, '%Y-%m-%d') else: end = datetime.utcnow() start = request.args.get('log-start') if start: start = datetime.strptime(start, '%Y-%m-%d') else: start = end - timedelta(weeks=3) log = Log.find_range(start, end+timedelta(days=1)) return render_template('log.html', log=log, start=start, end=end)