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

djbrown / hbscorez / 18227355346

03 Oct 2025 04:01PM UTC coverage: 46.467% (-0.1%) from 46.585%
18227355346

push

github

djbrown
instantiate UPDATING env  dynamically at runtime

fixes `OperationalError: no such table: base_env` on database creation

49 of 224 branches covered (21.88%)

Branch coverage included in aggregate %.

1 of 16 new or added lines in 8 files covered. (6.25%)

3 existing lines in 1 file now uncovered.

1700 of 3540 relevant lines covered (48.02%)

0.48 hits per line

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

52.38
/src/base/middleware/env.py
1
from base import models
1✔
2

3

4
def _ensure_env(name: str, default: models.Value, force: bool = False) -> models.Env:
1✔
UNCOV
5
    matches = models.Env.objects.filter(name=name)
×
UNCOV
6
    if matches.exists():
×
7
        match = matches[0]
×
8
        if force and match.value is not default.value:
×
9
            match.set_value(default)
×
10
        return match
×
11

UNCOV
12
    return models.Env.objects.create(name=name, value=default.value)
×
13

14

15
def updating():
1✔
NEW
16
    return _ensure_env("UPDATING", models.Value.FALSE)
×
17

18

19
class EnvironmentMiddleware:
1✔
20
    def __init__(self, get_response):
1✔
21
        self.get_response = get_response
1✔
22
        # One-time configuration and initialization.
23

24
    def __call__(self, request):
1✔
25
        # Code to be executed for each request before
26
        # the view (and later middleware) are called.
27
        request.env = {env.name: env.value for env in models.Env.objects.all()}
1✔
28
        request.global_message = models.GlobalMessage.objects.first()
1✔
29

30
        response = self.get_response(request)
1✔
31

32
        # Code to be executed for each request/response after
33
        # the view is called.
34

35
        return response
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