• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scoringengine / scoringengine / 23385248069

21 Mar 2026 05:50PM UTC coverage: 73.202% (-2.5%) from 75.69%
23385248069

push

github

RustyBower
Fix test to match DB fallback behavior for missing output files

The endpoint now returns check.output from DB (200) instead of 404
when the on-disk file doesn't exist.

3726 of 5090 relevant lines covered (73.2%)

0.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.3
/scoring_engine/web/__init__.py
1
import logging
1✔
2
import os
1✔
3

4
from flask import Flask
1✔
5
from flask_login import LoginManager
1✔
6

7
from scoring_engine.cache import agent_cache, cache
1✔
8
from scoring_engine.config import config
1✔
9
from scoring_engine.db import db
1✔
10
from scoring_engine.version import version_info
1✔
11

12
SECRET_KEY = os.urandom(128)
1✔
13

14

15
def create_app():
1✔
16
    app = Flask(__name__)
1✔
17

18
    app.config.update(DEBUG=config.debug)
1✔
19
    app.config.update(UPLOAD_FOLDER=config.upload_folder)
1✔
20
    app.secret_key = SECRET_KEY
1✔
21

22
    # Static file caching: 1 hour in debug mode, 1 week in production
23
    # Browsers will cache CSS/JS/images and not re-request until max-age expires
24
    if config.debug:
1✔
25
        app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 3600  # 1 hour
×
26
    else:
27
        app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 604800  # 1 week
1✔
28

29
    # Configure Flask-SQLAlchemy
30
    app.config["SQLALCHEMY_DATABASE_URI"] = config.db_uri
1✔
31
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
1✔
32
    app.config["SQLALCHEMY_ENGINE_OPTIONS"] = {
1✔
33
        "pool_pre_ping": True,  # Verify connections before using them
34
        "pool_recycle": 3600,  # Recycle connections after 1 hour
35
    }
36

37
    # Initialize Flask-SQLAlchemy with the app
38
    db.init_app(app)
1✔
39

40
    if not config.debug:
1✔
41
        log = logging.getLogger("werkzeug")
1✔
42
        log.setLevel(logging.ERROR)
1✔
43

44
    from scoring_engine.web.views import (
1✔
45
        about,
46
        admin,
47
        api,
48
        auth,
49
        flags,
50
        injects,
51
        notifications,
52
        overview,
53
        profile,
54
        scoreboard,
55
        services,
56
        stats,
57
        welcome,
58
        announcements,
59
    )
60

61
    cache.init_app(app)
1✔
62
    agent_cache.init_app(app)
1✔
63

64
    # Initialize login manager
65
    login_manager = LoginManager()
1✔
66
    login_manager.init_app(app)
1✔
67
    login_manager.login_view = "auth.login"
1✔
68
    login_manager.login_message_category = "info"
1✔
69
    login_manager.session_protection = "strong"
1✔
70

71
    # Register the user_loader function after initializing login_manager
72
    from scoring_engine.models.user import User
1✔
73

74
    @login_manager.user_loader
1✔
75
    def load_user(user_id):
1✔
76
        return db.session.get(User, int(user_id))
×
77

78
    app.register_blueprint(welcome.mod)
1✔
79
    app.register_blueprint(services.mod)
1✔
80
    app.register_blueprint(stats.mod)
1✔
81
    app.register_blueprint(scoreboard.mod)
1✔
82
    app.register_blueprint(profile.mod)
1✔
83
    app.register_blueprint(overview.mod)
1✔
84
    app.register_blueprint(notifications.mod)
1✔
85
    app.register_blueprint(injects.mod)
1✔
86
    app.register_blueprint(auth.mod)
1✔
87
    app.register_blueprint(flags.mod)
1✔
88
    app.register_blueprint(api.mod)
1✔
89
    app.register_blueprint(admin.mod)
1✔
90
    app.register_blueprint(about.mod)
1✔
91
    app.register_blueprint(announcements.mod)
1✔
92

93
    @app.context_processor
1✔
94
    def inject_version():
1✔
95
        return {'version_info': version_info}
1✔
96

97
    return app
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc