Skip to content

Commit

Permalink
Merge pull request #457 from tutorcruncher/origin/fixing-socket-server-2
Browse files Browse the repository at this point in the history
Fixing dependencies
  • Loading branch information
HenryTraill authored Jul 1, 2022
2 parents 234a8c7 + 4193bb9 commit ac34477
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Backend application for [TutorCruncher's](https://tutorcruncher.com) web integra

# LICENSE

Copyright TutorCruncher ltd. 2017 - 2021.
Copyright TutorCruncher ltd. 2017 - 2022.
All rights reserved.

## Deploying
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# this should install everything you need for development or testing, you might also want to install "ipython"
-r tcsocket/requirements.txt
-r tests/requirements.txt
aiohttp-devtools==0.13.1
aiohttp-devtools==1.0.post0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool:pytest]
testpaths = tests
addopts = --isort --aiohttp-loop uvloop --aiohttp-fast --tb=native
addopts = --isort --tb=native

[flake8]
max-line-length = 120
Expand Down
8 changes: 6 additions & 2 deletions tcsocket/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


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

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

@property
def pg_dsn(self):
return self.database_url.replace('gres://', 'gresql://')

@property
def images_url(self):
return f'https://{self.aws_bucket_name}'
Expand Down Expand Up @@ -66,7 +70,7 @@ def pg_port(self):
class Config:
fields = {
'port': {'env': 'PORT'},
'pg_dsn': {'env': 'DATABASE_URL'},
'database_url': {'env': 'DATABASE_URL'},
'redis_settings': {'env': 'REDISCLOUD_URL'},
'tc_api_root': {'env': 'TC_API_ROOT'},
'aws_access_key': {'env': 'AWS_ACCESS_KEY'},
Expand Down
18 changes: 9 additions & 9 deletions tcsocket/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
SQLAlchemy==1.3.23
SQLAlchemy==1.4.39
aiodns==3.0.0
aiohttp==3.8.1
aiopg==1.3.3
aiopg==1.3.4
aioredis==1.3.1
arq==0.22
boto3==1.20.44
boto3==1.24.21
cchardet==2.1.7
gunicorn==20.1.0
python-dateutil==2.8.2
pillow==9.0.0
pydantic[email]==1.9.0
pillow==9.1.1
pydantic[email]==1.9.1
raven==6.10.0
requests==2.27.1
requests==2.28.1
uvloop==0.16.0
ipython==7.31.1
pgcli==3.3.1
ipython-sql==0.4.0
ipython==8.4.0
pgcli==3.4.1
ipython-sql==0.4.1
yarl==1.7.2
16 changes: 8 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ async def geocoding_view(request):
return json_response(loc, status=status)


@pytest.yield_fixture(name='redis')
@pytest.fixture(name='redis')
async def _fix_redis(settings):
addr = settings.redis_settings.host, settings.redis_settings.port

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


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


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

Expand Down Expand Up @@ -383,7 +383,7 @@ def image_download_url(other_server):
@pytest.fixture
def settings(other_server):
return Settings(
pg_dsn=os.getenv('DATABASE_URL', DB_DSN),
database_url=os.getenv('DATABASE_URL', DB_DSN),
redis_database=7,
master_key=MASTER_KEY,
grecaptcha_secret='X' * 30,
Expand All @@ -393,9 +393,9 @@ def settings(other_server):
)


@pytest.yield_fixture(scope='session')
@pytest.fixture(scope='session')
def db():
settings_ = Settings(pg_dsn=os.getenv('DATABASE_URL', DB_DSN))
settings_ = Settings(database_url=os.getenv('DATABASE_URL', DB_DSN))
prepare_database(True, settings_)

engine = sa_create_engine(settings_.pg_dsn)
Expand All @@ -404,9 +404,9 @@ def db():
engine.dispose()


@pytest.yield_fixture
@pytest.fixture
def db_conn(loop, settings, db):
engine = loop.run_until_complete(aio_create_engine(settings.pg_dsn, loop=loop))
engine = loop.run_until_complete(aio_create_engine(settings.database_url, loop=loop))
conn = loop.run_until_complete(engine.acquire())
transaction = loop.run_until_complete(conn.begin())

Expand Down
12 changes: 6 additions & 6 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
attrs==21.4.0
black==21.12b0
coverage==6.2
black==22.6.0
coverage==6.4.1
flake8==4.0.1
isort==5.10.1
pycodestyle==2.8.0
pyflakes==2.4.0
pytest==6.2.5
pytest-aiohttp==0.3.0
pytest==7.1.2
pytest-aiohttp==1.0.4
pytest-cov==3.0.0
pytest-isort==2.0.0
pytest-mock==3.6.1
pytest-isort==3.0.0
pytest-mock==3.8.1
pytest-sugar==0.9.4
pytest-toolbox==0.4

0 comments on commit ac34477

Please sign in to comment.