Skip to content

Commit 4193bb9

Browse files
committed
Lets go
1 parent 234a8c7 commit 4193bb9

File tree

7 files changed

+32
-28
lines changed

7 files changed

+32
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Backend application for [TutorCruncher's](https://tutorcruncher.com) web integra
88

99
# LICENSE
1010

11-
Copyright TutorCruncher ltd. 2017 - 2021.
11+
Copyright TutorCruncher ltd. 2017 - 2022.
1212
All rights reserved.
1313

1414
## Deploying

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# this should install everything you need for development or testing, you might also want to install "ipython"
22
-r tcsocket/requirements.txt
33
-r tests/requirements.txt
4-
aiohttp-devtools==0.13.1
4+
aiohttp-devtools==1.0.post0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool:pytest]
22
testpaths = tests
3-
addopts = --isort --aiohttp-loop uvloop --aiohttp-fast --tb=native
3+
addopts = --isort --tb=native
44

55
[flake8]
66
max-line-length = 120

tcsocket/app/settings.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class Settings(BaseSettings):
13-
pg_dsn: Optional[str] = 'postgresql://postgres@localhost:5432/socket'
13+
database_url: Optional[str] = 'postgresql://postgres@localhost:5432/socket'
1414
redis_settings: RedisSettings = 'redis://localhost:6379'
1515
redis_database: int = 0
1616

@@ -39,6 +39,10 @@ def parse_redis_settings(cls, v):
3939
database=int((conf.path or '0').strip('/')),
4040
)
4141

42+
@property
43+
def pg_dsn(self):
44+
return self.database_url.replace('gres://', 'gresql://')
45+
4246
@property
4347
def images_url(self):
4448
return f'https://{self.aws_bucket_name}'
@@ -66,7 +70,7 @@ def pg_port(self):
6670
class Config:
6771
fields = {
6872
'port': {'env': 'PORT'},
69-
'pg_dsn': {'env': 'DATABASE_URL'},
73+
'database_url': {'env': 'DATABASE_URL'},
7074
'redis_settings': {'env': 'REDISCLOUD_URL'},
7175
'tc_api_root': {'env': 'TC_API_ROOT'},
7276
'aws_access_key': {'env': 'AWS_ACCESS_KEY'},

tcsocket/requirements.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
SQLAlchemy==1.3.23
1+
SQLAlchemy==1.4.39
22
aiodns==3.0.0
33
aiohttp==3.8.1
4-
aiopg==1.3.3
4+
aiopg==1.3.4
55
aioredis==1.3.1
66
arq==0.22
7-
boto3==1.20.44
7+
boto3==1.24.21
88
cchardet==2.1.7
99
gunicorn==20.1.0
1010
python-dateutil==2.8.2
11-
pillow==9.0.0
12-
pydantic[email]==1.9.0
11+
pillow==9.1.1
12+
pydantic[email]==1.9.1
1313
raven==6.10.0
14-
requests==2.27.1
14+
requests==2.28.1
1515
uvloop==0.16.0
16-
ipython==7.31.1
17-
pgcli==3.3.1
18-
ipython-sql==0.4.0
16+
ipython==8.4.0
17+
pgcli==3.4.1
18+
ipython-sql==0.4.1
1919
yarl==1.7.2

tests/conftest.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ async def geocoding_view(request):
321321
return json_response(loc, status=status)
322322

323323

324-
@pytest.yield_fixture(name='redis')
324+
@pytest.fixture(name='redis')
325325
async def _fix_redis(settings):
326326
addr = settings.redis_settings.host, settings.redis_settings.port
327327

@@ -334,7 +334,7 @@ async def _fix_redis(settings):
334334
await redis.wait_closed()
335335

336336

337-
@pytest.yield_fixture(name='worker_ctx')
337+
@pytest.fixture(name='worker_ctx')
338338
async def _fix_worker_ctx(redis, settings, db_conn):
339339
session = ClientSession(timeout=ClientTimeout(total=10))
340340
ctx = dict(settings=settings, pg_engine=MockEngine(db_conn), session=session, redis=redis)
@@ -344,7 +344,7 @@ async def _fix_worker_ctx(redis, settings, db_conn):
344344
await session.close()
345345

346346

347-
@pytest.yield_fixture(name='worker')
347+
@pytest.fixture(name='worker')
348348
async def _fix_worker(redis, worker_ctx):
349349
worker = Worker(functions=WorkerSettings.functions, redis_pool=redis, burst=True, poll_delay=0.01, ctx=worker_ctx)
350350

@@ -383,7 +383,7 @@ def image_download_url(other_server):
383383
@pytest.fixture
384384
def settings(other_server):
385385
return Settings(
386-
pg_dsn=os.getenv('DATABASE_URL', DB_DSN),
386+
database_url=os.getenv('DATABASE_URL', DB_DSN),
387387
redis_database=7,
388388
master_key=MASTER_KEY,
389389
grecaptcha_secret='X' * 30,
@@ -393,9 +393,9 @@ def settings(other_server):
393393
)
394394

395395

396-
@pytest.yield_fixture(scope='session')
396+
@pytest.fixture(scope='session')
397397
def db():
398-
settings_ = Settings(pg_dsn=os.getenv('DATABASE_URL', DB_DSN))
398+
settings_ = Settings(database_url=os.getenv('DATABASE_URL', DB_DSN))
399399
prepare_database(True, settings_)
400400

401401
engine = sa_create_engine(settings_.pg_dsn)
@@ -404,9 +404,9 @@ def db():
404404
engine.dispose()
405405

406406

407-
@pytest.yield_fixture
407+
@pytest.fixture
408408
def db_conn(loop, settings, db):
409-
engine = loop.run_until_complete(aio_create_engine(settings.pg_dsn, loop=loop))
409+
engine = loop.run_until_complete(aio_create_engine(settings.database_url, loop=loop))
410410
conn = loop.run_until_complete(engine.acquire())
411411
transaction = loop.run_until_complete(conn.begin())
412412

tests/requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
attrs==21.4.0
2-
black==21.12b0
3-
coverage==6.2
2+
black==22.6.0
3+
coverage==6.4.1
44
flake8==4.0.1
55
isort==5.10.1
66
pycodestyle==2.8.0
77
pyflakes==2.4.0
8-
pytest==6.2.5
9-
pytest-aiohttp==0.3.0
8+
pytest==7.1.2
9+
pytest-aiohttp==1.0.4
1010
pytest-cov==3.0.0
11-
pytest-isort==2.0.0
12-
pytest-mock==3.6.1
11+
pytest-isort==3.0.0
12+
pytest-mock==3.8.1
1313
pytest-sugar==0.9.4
1414
pytest-toolbox==0.4

0 commit comments

Comments
 (0)