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

gcivil-nyu-org / team4-wed-fall25 / 89

25 Nov 2025 10:36PM UTC coverage: 73.867% (-0.9%) from 74.758%
89

push

travis-pro

web-flow
Merge pull request #92 from aayush226/aayush-add-coverage

test: add unit tests for full coverage and cleanup logic

79 of 81 new or added lines in 3 files covered. (97.53%)

183 existing lines in 2 files now uncovered.

1190 of 1611 relevant lines covered (73.87%)

0.74 hits per line

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

88.1
/note2web/settings.py
1
"""
2
Django settings for note2web project.
3

4
Generated by 'django-admin startproject' using Django 4.2.25.
5

6
For more information on this file, see
7
https://docs.djangoproject.com/en/4.2/topics/settings/
8

9
For the full list of settings and their values, see
10
https://docs.djangoproject.com/en/4.2/ref/settings/
11
"""
12

13
from pathlib import Path
1✔
14
import os
1✔
15
import tempfile
1✔
16
from dotenv import load_dotenv
1✔
17

18
# Build paths inside the project like this: BASE_DIR / 'subdir'.
19
BASE_DIR = Path(__file__).resolve().parent.parent
1✔
20

21
if load_dotenv is not None:
1✔
22
    env_path = BASE_DIR / ".env"
1✔
23
    if env_path.exists():
1✔
UNCOV
24
        load_dotenv(env_path)
×
25

26

27
# Quick-start development settings - unsuitable for production
28
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
29

30
# ---- Secrets (from environment) ----
31
SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY")
1✔
32
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
1✔
33

34
if not SECRET_KEY:
1✔
35
    if os.environ.get("CI") or os.environ.get("TRAVIS"):
1✔
36
        SECRET_KEY = "dummy-key-for-ci"
1✔
37
        print("INFO: Using dummy SECRET_KEY for CI environment.")
1✔
38
    else:
NEW
39
        raise RuntimeError("DJANGO_SECRET_KEY is not set in environment")
×
40

41
# Optional: warn if OpenAI key missing (AI features will just fail gracefully)
42
if not OPENAI_API_KEY:
1✔
UNCOV
43
    print(
×
44
        "WARNING: OPENAI_API_KEY is not set – AI features depending on OpenAI will not work."
45
    )
46

47

48
# SECURITY WARNING: don't run with debug turned on in production!
49
DEBUG = True
1✔
50

51
ALLOWED_HOSTS = [
1✔
52
    "*",
53
]
54

55

56
# Application definition
57

58
INSTALLED_APPS = [
1✔
59
    "django.contrib.admin",
60
    "django.contrib.auth",
61
    "django.contrib.contenttypes",
62
    "django.contrib.sessions",
63
    "django.contrib.messages",
64
    "django.contrib.staticfiles",
65
    "channels",
66
    "note2webapp",
67
    "widget_tweaks",
68
]
69

70
MIDDLEWARE = [
1✔
71
    "django.middleware.security.SecurityMiddleware",
72
    "django.contrib.sessions.middleware.SessionMiddleware",
73
    "django.middleware.common.CommonMiddleware",
74
    "django.middleware.csrf.CsrfViewMiddleware",
75
    "django.contrib.auth.middleware.AuthenticationMiddleware",
76
    "django.contrib.messages.middleware.MessageMiddleware",
77
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
78
]
79

80
ROOT_URLCONF = "note2web.urls"
1✔
81

82
TEMPLATES = [
1✔
83
    {
84
        "BACKEND": "django.template.backends.django.DjangoTemplates",
85
        "DIRS": [
86
            os.path.join(BASE_DIR, "note2webapp", "templates"),  # Add this line
87
        ],
88
        "APP_DIRS": True,
89
        "OPTIONS": {
90
            "context_processors": [
91
                "django.template.context_processors.debug",
92
                "django.template.context_processors.request",
93
                "django.contrib.auth.context_processors.auth",
94
                "django.contrib.messages.context_processors.messages",
95
            ],
96
        },
97
    },
98
]
99

100
WSGI_APPLICATION = "note2web.wsgi.application"
1✔
101
ASGI_APPLICATION = "note2web.asgi.application"
1✔
102

103
# Channel layers configuration
104
# Use Redis in production (for multi-instance support), InMemory for development
105
if os.environ.get("REDIS_URL"):
1✔
106
    # Production: Use Redis URL (e.g., from ElastiCache)
UNCOV
107
    CHANNEL_LAYERS = {
×
108
        "default": {
109
            "BACKEND": "channels_redis.core.RedisChannelLayer",
110
            "CONFIG": {
111
                "hosts": [os.environ.get("REDIS_URL")],
112
            },
113
        },
114
    }
115
elif os.environ.get("REDIS_HOST"):
1✔
116
    # Production: Use Redis with host/port
UNCOV
117
    CHANNEL_LAYERS = {
×
118
        "default": {
119
            "BACKEND": "channels_redis.core.RedisChannelLayer",
120
            "CONFIG": {
121
                "hosts": [
122
                    (
123
                        os.environ.get("REDIS_HOST", "localhost"),
124
                        int(os.environ.get("REDIS_PORT", 6379)),
125
                    )
126
                ],
127
            },
128
        },
129
    }
130
else:
131
    # Development: Use in-memory channel layer
132
    CHANNEL_LAYERS = {"default": {"BACKEND": "channels.layers.InMemoryChannelLayer"}}
1✔
133

134

135
# Database
136
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
137

138
DATABASES = {
1✔
139
    "default": {
140
        "ENGINE": "django.db.backends.sqlite3",
141
        "NAME": os.path.join(tempfile.gettempdir(), "db.sqlite3"),
142
    }
143
}
144

145

146
# Password validation
147
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
148

149
AUTH_PASSWORD_VALIDATORS = [
1✔
150
    {
151
        "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
152
    },
153
    {
154
        "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
155
    },
156
    {
157
        "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
158
    },
159
    {
160
        "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
161
    },
162
]
163

164

165
# Internationalization
166
# https://docs.djangoproject.com/en/4.2/topics/i18n/
167

168
LANGUAGE_CODE = "en-us"
1✔
169

170
TIME_ZONE = "UTC"
1✔
171

172
USE_I18N = True
1✔
173

174
USE_TZ = True
1✔
175

176

177
# Static files (CSS, JavaScript, Images)
178
# https://docs.djangoproject.com/en/4.2/howto/static-files/
179

180
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
1✔
181
STATIC_URL = "/static/"
1✔
182
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
1✔
183
MEDIA_URL = "/media/"
1✔
184

185
# Default primary key field type
186
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
187

188
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
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