|
1 | | -import os |
| 1 | + |
2 | 2 | import redis |
3 | 3 | from flask.views import MethodView |
| 4 | +from flask_jwt_extended import (create_access_token, create_refresh_token, |
| 5 | + get_jwt, get_jwt_identity, jwt_required) |
4 | 6 | from flask_smorest import Blueprint, abort |
5 | | -from flask_jwt_extended import ( |
6 | | - create_access_token, |
7 | | - create_refresh_token, |
8 | | - get_jwt_identity, |
9 | | - get_jwt, |
10 | | - jwt_required, |
11 | | -) |
12 | 7 | from passlib.hash import pbkdf2_sha256 |
13 | | -from sqlalchemy import or_ |
14 | 8 | from rq import Queue |
| 9 | +from sqlalchemy import or_ |
15 | 10 |
|
16 | | -from tasks import send_user_registration_email |
17 | | - |
| 11 | +import config |
| 12 | +from blocklist import BLOCKLIST |
18 | 13 | from db import db |
19 | 14 | from models import UserModel |
20 | | -from schemas import UserSchema, UserRegisterSchema |
21 | | -from blocklist import BLOCKLIST |
| 15 | +from schemas import UserRegisterSchema, UserSchema |
| 16 | +from tasks import send_user_registration_email |
22 | 17 |
|
23 | 18 | blp = Blueprint("Users", "users", description="Operations on users") |
24 | | -connection = redis.from_url( |
25 | | - os.getenv("REDIS_URL") |
26 | | -) # Get this from Render.com or run in Docker |
27 | | -queue = Queue("emails", connection=connection) |
| 19 | +if isinstance(config.config, config.TestConfig): |
| 20 | + import fakeredis |
| 21 | + connection = fakeredis.FakeStrictRedis() |
| 22 | + queue = Queue("emails", is_async=False, connection=connection) |
| 23 | +else: |
| 24 | + connection = redis.from_url(config.config.REDIS_URL) |
| 25 | + queue = Queue("emails", connection=connection) |
28 | 26 |
|
29 | 27 |
|
30 | 28 | @blp.route("/register") |
|
0 commit comments